标签:
(1)情景:在iOS8.1中,我们通常会利用如下语句,设置全局的导航条按钮item的主题
UIBarButtonItem *item=[UIBarButtonItem appearance];
NSMutableDictionary *textAttrs=[NSMutableDictionary dictionary];
textAttrs[NSForegroundColorAttributeName]=[UIColor orangeColor];
[item setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
[item setTitleTextAttributes:textAttrs forState:UIControlStateHighlighted];
NSMutableDictionary *dTextAttrs=[NSMutableDictionary dictionaryWithDictionary:textAttrs];
dTextAttrs[NSForegroundColorAttributeName]=[UIColor grayColor];
[item setTitleTextAttributes:dTextAttrs forState:UIControlStateDisabled];-(void)setupNavBar{
self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"发送" style:UIBarButtonItemStyleDone target:self action:@selector(send)];
self.navigationItem.rightBarButtonItem.enabled=NO;
}将上面的设置为disabled的语句放置在viewWillAppear中。
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
//如果把下面这一句写在ViewDidLoad中,disabled的item颜色没有效果
self.navigationItem.rightBarButtonItem.enabled=NO;
}【iOS开发-103】解决方案:iOS8.1中UIBarButtonItem的setTitleTextAttributes对Disabled颜色设置无效
标签:
原文地址:http://blog.csdn.net/weisubao/article/details/42709349