我有一个分配给 IOS7 上的 navigationItem.leftBarButtonItem 的图像。当我从设计师那里得到它时,它在导航栏的背景上看起来很好。但是当我在 IOS7 中实现它时,它变得苍白,几乎消失了。
这是它的设置方式:
UIBarButtonItem *button = [[barButtonItemClass alloc] initWithImage:[UIImage imageNamed:@"nav_menu_icon.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(showLeft:)];
viewController.navigationItem.leftBarButtonItem = button;
这就是它的外观(图片来自我的设计师):
这是实现时的样子(在模拟器或手机上):
解决方案是什么?
最佳答案
您应该将导航栏的色调设置为为栏中的所有项目着色。
一个不错的解决方案是使用 UIAppearance
iOS 5 中引入的协议(protocol)。
在你 AppDelegate 的 applicationDidFinishLaunching
方法把下面的代码:
[[UINavigationBar appearance] setTintColor: [UIColor whiteColor]];
请注意,我目前无法尝试该代码。
干杯!
关于ios - Controller navigationItem.leftBarButtonItem 在 IOS7 中改变颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22633383/