iphone - ios7 xcode 5 GM : color of UIBarButtonItem and selected UISegmentedControl part on iOS 6 device keep default color

标签 iphone

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

self.navigationController.navigationBar.tintColor 

-更改栏的颜色,但不更改项目的颜色

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

- 不起作用,颜色同样错误

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

- 不起作用,颜色同样错误

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

           close.tintColor = [UIColor greenColor];

- 不起作用,颜色同样错误

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

我看到未选定的片段具有正确的颜色,但选定的片段具有相同的错误颜色。

有什么想法吗?

最佳答案

感谢 WWDC 2013 - 为 iOS 7 定制应用程序的外观,弄清楚需要做什么。

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

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

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

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

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

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

}

关于iphone - ios7 xcode 5 GM : color of UIBarButtonItem and selected UISegmentedControl part on iOS 6 device keep default color,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18817626/

相关文章:

iphone - 将自定义 UITableViewCell 中的 UITextField 移动到屏幕中央,这样键盘就不会覆盖它

iphone - 调用方法时以编程方式创建的 UIButton 崩溃

iphone - UITableViewDelegate 和 DataSource 在 MVC 中放在哪里?

iphone - 在 iPhone 中的两个 View Controller 之间使用委托(delegate)

facebook - iPhone - UIWebview 不会将身份验证保存到站点

iphone - 扩展 UIScrollView 并监控滚动事件

iphone - 在构建表格时如何在 UITableViewController 中显示 View ?

iphone - 在 iPhone 中实现 Google+ 时出错

iOS:生成随机对象 ID

iphone - 如果设置为 YES,UIView layer.masksToBounds 会做什么?