Xcode 4.2中的外观不起作用

时间:2012-01-10 19:23:00

标签: objective-c xcode4.2 appearance

我在我的AppDelegate中使用didFinishLaunchingWithOptions方法添加了此代码:

[[UINavigationBar appearance]setBackgroundColor:[UIColor colorWithRed:221/256.0 green:36/256.0 blue:40/256.0 alpha:0.0]];

[[UITabBar appearance] setBackgroundColor:[UIColor colorWithRed:221/256.0 green:36/256.0 blue:40/256.0 alpha:0.0]];

但NavigationBar和TabBar没有改变它们的颜色。我做错了什么? 感谢

1 个答案:

答案 0 :(得分:1)

使用setTintColor:代替setBackgroundColor:

[[UINavigationBar appearance] setTintColor:[UIColor colorWithRed:221/256.0 green:36/256.0 blue:40/256.0 alpha:0.0]];
[[UITabBar appearance] setTintColor:[UIColor colorWithRed:221/256.0 green:36/256.0 blue:40/256.0 alpha:0.0]];