[英]setting tint color for selected tab in UITabBar
在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或更高版本上运行 :
+ (BOOL)isIOS7OrHigher
{
float versionNumber = floor(NSFoundationVersionNumber);
return versionNumber > NSFoundationVersionNumber_iOS_6_1;
}
希望这可以帮助!
只需在UITabBar
类的User Defined Runtime Attribute中添加颜色类型的tintColor
。
仍然在寻找非活动标签的类似方法......任何人都知道吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.