Share via


UITextAttributes 类

定义

用于描述要在某些用户界面元素上设置的文本属性的类型。

public class UITextAttributes
type UITextAttributes = class
继承
UITextAttributes

注解

通常,开发人员创建此类的实例并填写各种属性来配置所需的文本属性。

例如,以下代码可用于更改 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);

可以在 UITextAttributes 的构造函数中使用代码完成,而无需记住要设置的属性。 上面的示例呈现如下:

从 iOS5 起,可以在以下项上设置文本属性:UIBarItemUINavigationBarUISearchBarUISegmentedControl

构造函数

UITextAttributes()

默认构造函数不执行任何作用,必须填充至少一个属性才能使它有用。

字段

Font

用于呈现文本的字体。

TextColor

要用于文本的颜色。

TextShadowColor

如果设置 TextShadowOffset,则为用于文本阴影的颜色。

TextShadowOffset

描述文本与其阴影之间的距离的偏移量。

适用于