我有一些代码来定制标签栏。我使用外观框架来做到这一点。该应用程序是iOS 5+,所以这应该工作,据我所知。我的代码是这样的:
NSDictionary *textAttributesNormal = @{
UITextAttributeTextColor: [UIColor colorWithRed:0.04f green:0.25f blue:0.56f alpha:1.00f],
UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetMake(0, 0)]
};
NSDictionary *textAttributesSelected = @{
UITextAttributeTextColor: [UIColor colorWithWhite:1.0 alpha:1.0]
};
[[UITabBar appearance] setTintColor:[UIColor colorWithRed:0.53f green:0.76f blue:0.91f alpha:1.00f]];
[[UITabBarItem appearance] setTitleTextAttributes:textAttributesNormal forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes:textAttributesSelected forState:UIControlStateSelected];
我在委托的applicationDidFinishLaunching方法中这样做。这段代码在iOS6上完美地工作,并按预期工作。但在iOS 5上,它什么都不做。它不会抛出任何警告或错误。
在模拟器和实际设备上的行为是相同的。我可以在界面构建器中设置色调,然后它就能在iOS5上工作了。但是我没有找到一种方法来设置文本属性的选项栏项目通过IF。
我感谢任何帮助或提示!: -)最好的祝愿,托马斯。
好吧,外观代码并不是真正的问题。如前所述,我在
中这样做了- (void)applicationDidFinishLaunching:(UIApplication *)application
这个应用程序有点老了,苹果文档说,在iOS3+上应该使用
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
我改变了它,现在它可以正常工作了