改变自定义uibarbuttonitem(iOS7)的颜色

时间:2014-03-22 18:09:29

标签: ios objective-c ios7 uibarbuttonitem uitoolbar

我有5个UIBarButtonItems,只会改变2的颜色。 我怎么能在xcode 5中做到这一点?

非常感谢您的回答!

我必须在AppDelegate.m中添加到此代码中吗?

[[UINavigationBar appearance] setBarTintColor:UIColorFromRGB (0x34AADC)];

[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleLightContent];

[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];

[[UIBarButtonItem appearance] setTintColor:[UIColor whiteColor]];

[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];

[[UIToolbar appearance] setBarTintColor:UIColorFromRGB (0x34AADC)];

2 个答案:

答案 0 :(得分:1)

还有一种方法如下:

[[UIBarButtonItem appearanceWhenContainedIn:[<The class in which you want to set custom color> class], nil] setTintColor:<myColor>];

答案 1 :(得分:0)

你在某处为这些创建了一个对象。例如:

UINavigationController *navController=[[UINavigationController alloc]init];

现在你应该这样做:

 [navController.navigationBar setBarStyle:UIBarStyleBlackTranslucent];

不要设置整个UINavigationController,设置对象。