ios7 xcode 5 GM:UIBarButtonItem的颜色和iOS 6设备上选定的UISegmentedControl部分保持默认颜色 [英] ios7 xcode 5 GM: color of UIBarButtonItem and selected UISegmentedControl part on iOS 6 device keep default color

查看:128
本文介绍了ios7 xcode 5 GM:UIBarButtonItem的颜色和iOS 6设备上选定的UISegmentedControl部分保持默认颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在将ios6应用程序移植到ios7 sdk(使用Xcode 5和mavericks),我试图更改UIBarButtonItem颜色,这是我尝试做的:

i'm porting now ios6 app to ios7 sdk (with Xcode 5 and mavericks) and i tried to change UIBarButtonItem color, here is what i try to do:

self.navigationController.navigationBar.tintColor 

- 改变颜色对于栏而不是项目

- make changes color for bar but not for items

[[UINavigationBar appearance] setTintColor:[UIColor greenColor]];
[[UIBarButtonItem appearance] setTintColor:[UIColor greenColor]];

- 不起作用,颜色相同

- doesn't work, same wrong color

self.navigationItem.rightBarButtonItem.tintColor = [UIColor greenColor];
self.navigationItem.leftBarButtonItem.tintColor = [UIColor greenColor];    

- 不起作用,颜色相同

- doesn't work, same wrong color

    UIBarButtonItem *close = [[UIBarButtonItem alloc] 
                             initWithTitle:NSLocalizedString(@"Close",@"") 
                                     style:UIBarButtonItemStyleDone target:self
                                    action:@selector(closeAddressBook:)];

           close.tintColor = [UIColor greenColor];

- 不起作用,颜色相同

- doesn't work, same wrong color

  for self.filterSegment.tintColor =  [UIColor greenColor] where UISegmentedControl *filterSegment;

我看到未选择的段颜色正确,但选定的段颜色相同。

i see unselected segment with correct color, but selected segment is a same wrong color.

任何想法?

推荐答案

通过WWDC了解需要做什么2013 - 自定义应用程序在iOS 7中的外观。

Figured out what needs to be done, thanks to WWDC 2013 - Customizing Your App’s Appearance for iOS 7.

self.navigationController.navigationBar.tintColor = [UIColor redColor];

这将过滤到您应用中的其他视图,因此放置在初始屏幕上,如果您按到下一个屏幕,您将看到后退按钮也是红色。

This will filter down into the other views in your app, so place on initial screen, and if you push to the next screen you will see that the back button is also red.

要更改导航栏颜色,请使用

To change the navigation bar colour use

self.navigationController.navigationBar.barTintColor = [UIColor greenColor];

如果你的应用程序适用于低于iOS7的设备,你应该检查它是否响应选择器

If you are making your app work for devices less than iOS7, you should check it responds to the selector

if([self.navigationController.navigationBar respondsToSelector:@selector(barTintColor)]) {

}

这篇关于ios7 xcode 5 GM:UIBarButtonItem的颜色和iOS 6设备上选定的UISegmentedControl部分保持默认颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆