gpt4 book ai didi

ios - 为 UITabBar 中的选定选项卡设置色调颜色

转载 作者:可可西里 更新时间:2023-11-01 03:25:30 25 4
gpt4 key购买 nike

在 Xcode 5 Dev Preview 2 中,我能够执行以下操作:

[[UITabBar appearance] setTintColor:[UIColor whiteColor]];//选中图片和文字的颜色(白色)

在 Xcode 5 Dev Preview 3 中,同一行代码抛出异常(见下文)。异常表明我可能想要使用“barTintColor”——但我没有——因为这是整个 UITabBar 的颜色。如何在 UITabBar 中设置所选图像和文本的颜色?

Xcode 5 Dev Preview 3 中的新异常:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-setTintColor: is not allowed for use with the appearance proxy. Perhaps you want to use the barTintColor property.'

谢谢

最佳答案

我在最新的 Xcode 5 (5.0.2) 中没有看到这一点,但我知道您想调用不同的方法来设置所选图像色调颜色,具体取决于您是在 iOS 6 还是 7 上运行. 这是我的一个应用程序中的一些示例代码:

if ([RFSUtilities isIOS7OrHigher])
{
[[UITabBar appearance] setTintColor:[UIColor whiteColor]];
}
else
{
[[UITabBar appearance] setSelectedImageTintColor:[UIColor whiteColor]];
}

+[RFSUtilities isIOS7OrHigher] 只是检查我们是否在 iOS 7 或更高版本上运行 the proper version check :

+ (BOOL)isIOS7OrHigher
{
float versionNumber = floor(NSFoundationVersionNumber);
return versionNumber > NSFoundationVersionNumber_iOS_6_1;
}

希望这对您有所帮助!

关于ios - 为 UITabBar 中的选定选项卡设置色调颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20783193/

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