gpt4 book ai didi

ios - [_UIBarItemAppearance setTitleColor:forState:]:无法识别的选择器已发送到实例

转载 作者:行者123 更新时间:2023-12-01 17:27:23 26 4
gpt4 key购买 nike

我正在尝试为所有UIBarButtonItem设置标题颜色

当我使用时:

 [[UIBarButtonItem appearance] setTitleColor:normalTitleColor forState:UIControlStateNormal];

我得到:
-[_UIBarItemAppearance setTitleColor:forState:]: unrecognized selector sent to instance 0xd695e30

我的背景图片没有任何问题,但标题颜色效果不佳。

最佳答案

这是因为它在UIBarButtonItem类或super class中不存在

您可以在UIBarItem中使用此方法定义

 setTitleTextAttributes:forState:  

设置给定控件状态的标题文本属性。
- (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state  

参数
属性

包含文本属性的键值对的字典。
您可以使用NSString UIKit Additions Reference中列出的键来指定字体,文本颜色,文本阴影颜色和文本阴影偏移。
状态

您要为其设置标题文本属性的控件状态。
可用性
在iOS 5.0及更高版本中可用。
也可以看看
– titleTextAttributesForState:  

宣告
UIBarItem.h  

关于ios - [_UIBarItemAppearance setTitleColor:forState:]:无法识别的选择器已发送到实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8981197/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com