更改导航栏标题

怎么办setTitleTextAttributes:forState在UIBarItem在iOS的5.0? 如何设置字典?不能让它工作,不是很清楚了... 从 setTitleTextAttributes:forState: 设置给定控制状态标题的文本属性。 - (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];
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值