iOS Guides | Samples

MonoTouch.UIKit.UITextAttributes Class

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

See Also: UITextAttributes

Syntax

public class 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:

C# Example

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.

Requirements

Namespace: MonoTouch.UIKit
Assembly: monotouch (in monotouch.dll)
Assembly Versions: 0.0.0.0

The members of MonoTouch.UIKit.UITextAttributes are listed below.

See Also: Object

Public Constructors

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

Public Fields

FontUIFont. The font to use to render the text.
TextColorUIColor. The color to use for the text.
TextShadowColorUIColor. If you set the TextShadowOffset, the color to use for the shadow of the text.
TextShadowOffsetUIOffset. The offset describing the distance between the text and its shadow.