怎么办setTitleTextAttributes:forState在UIBarItem在iOS的5.0? 如何设置字典?不能让它工作,不是很清楚了... 从 setTitleTextAttributes:forState: 设置给定控制状态标题的文本属性。
-------------------------------------------------------------------------------------------------------------------------
1. 示例代码:
2. 下面是phix23的代码,只需用一个更新的,而且我觉得更清洁,语法:
3.
- (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state
属性:一个包含键-值对的文本属性字典。您可以指定字体,文字颜色,文字阴影颜色,文字阴影中的NSString UIKit中添置参考列出的键。 状态:您要设置文本的控制状态属性的称号。 可用性:可提供的iOS 5.0及更高版本。
1. 示例代码:
[[UIBarItem appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:220.0/255.0 green:104.0/255.0 blue:1.0/255.0 alpha:1.0], UITextAttributeTextColor,
[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0], UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset,
[UIFont fontWithName:@"AmericanTypewriter" size:0.0], UITextAttributeFont,
nil]
forState:UIControlStateNormal];
2. 下面是phix23的代码,只需用一个更新的,而且我觉得更清洁,语法:
[[UIBarItem appearance] setTitleTextAttributes:@{
UITextAttributeTextColor: [UIColor colorWithRed:220.0/255.0 green:104.0/255.0 blue:1.0/255.0 alpha:1.0],
UITextAttributeTextShadowColor: [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0],
UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetMake(0, 1)],
UITextAttributeFont: [UIFont fontWithName:@"AmericanTypewriter" size:0.0]}
forState: UIControlStateNormal];
3.
[self.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:[UIColor whiteColor], nil] forKeys:[NSArray arrayWithObjects:UITextAttributeTextColor, nil]] forState:UIControlStateNormal];