1
我已经创建了三个条形按钮项目的UIToolBar。当使用默认字体和字体大小时,所有效果都很好。但是,字体有点太大,我想调整它的大小。我使用以下代码成功地在正常状态下自定义字体大小和颜色,但是当禁用按钮#1时,对于启用和禁用状态,文本颜色都保持黑色 - 即它不会将颜色更改为灰色。无法更改禁用状态下的UIBarButtonItem颜色属性
NSDictionary *ena = @{NSFontAttributeName:[UIFont fontWithName:@"Helvetica" size:12.0], NSForegroundColorAttributeName:
[UIColor blackColor]};
NSDictionary *dis = @{NSFontAttributeName:[UIFont fontWithName:@"Helvetica" size:12.0], NSForegroundColorAttributeName:
[UIColor grayColor]};
[[UIBarButtonItem appearance] setTitleTextAttributes:ena forState:UIControlStateNormal];
[[UIBarButtonItem appearance] setTitleTextAttributes:dis forState:UIControlStateDisabled];
我很感激我对上述代码出错的一些反馈。