我现在正在将 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/