Upravit

Sdílet prostřednictvím


UITextAttributes Class

Definition

Type used to describe the text attributes to set on some user interface elements.

public class UITextAttributes
type UITextAttributes = class
Inheritance
UITextAttributes

Remarks

Typically developers create an instance of this class and fill out the various properties to configure the desired text attributes.

For example, the following code can be used to change the style of the UINavigationBar:

var attrs = new UITextAttributes () {
	Font = UIFont.FromName ("Chalkduster", 20),
	TextColor = UIColor.Red,
	TextShadowColor = UIColor.Black,
	TextShadowOffset = new UIOffset (6, 6)
};
myNavController.NavigationBar.SetTitleTextAttributes (attrs);

You can use code-completion inside the constructor for UITextAttributes without having to remember the properties that you want to set. The above sample renders like this:

As of iOS5, you can set the text attributes on the following items: UIBarItem, UINavigationBar, UISearchBar and UISegmentedControl.

Constructors

UITextAttributes()

The default constructor does nothing, you must fill at least one property for this to be useful.

Fields

Font

The font to use to render the text.

TextColor

The color to use for the text.

TextShadowColor

If you set the TextShadowOffset, the color to use for the shadow of the text.

TextShadowOffset

The offset describing the distance between the text and its shadow.

Applies to