我正在尝试在textAttributes
的{{1}}上设置已停用的UIBarButtonItem
。
我像这样创建我的项目:
UIToolbar
然而,当我设置NSDictionary *enabledAttrs = @{ NSFontAttributeName : font,
NSForegroundColorAttributeName : color };
NSDictionary *disabledAttrs = @{ NSFontAttributeName : font,
NSForegroundColorAttributeName : [UIColor grayColor] };
[item setTitleTextAttributes:enabledAttrs forState:UIControlStateNormal];
[item setTitleTextAttributes:disabledAttrs forState:UIControlStateDisabled];
时,该按钮被禁用(它不会触发其动作)但它不会尊重其item.enabled = NO
- 它仍然显示为正常状态。为什么呢?
答案 0 :(得分:0)
创建UIButton并使用UIBarbutton进行换行,我认为它应该可行。
UIButton *uiButton = [[UIButton alloc] init];
[uiButton setTitleColor: color1 forState: UIControlStateNormal];
[uiButton setTitleColor: color2 forState: UIControlStateDisabled];
UIBarButtonItem *uiBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:uiButton];