UIBarButtonItem色彩与设备上的颜色不同

时间:2015-02-26 11:02:12

标签: ios iphone swift uibarbuttonitem uicolor

我的项目中每个UIBarButtonItem's至少有一个UIViewController,所有内容都在UINavigationController中,UINavigationBar为蓝色,UIBarButtonItem's应为白色。< / p>

在模拟器中它们是白色的......但在设备中它们是浅灰色的,如下图所示:

模拟器 Simulator

设备 Device

他们运行完全相同的代码和完全相同的ios版本ios 8.1

我目前将故事板中的色调颜色设置为白色,但我也尝试过:

// In appdelegate
UINavigationBar.appearance().barTintColor = UIColor(hex: 0x4a9bcb, alpha: 1.0)
UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName:UIFont(name: "FuturaLT-Bold", size: 16)!, NSForegroundColorAttributeName:UIColor(white: 1.0, alpha: 1.0)]
UIBarButtonItem.appearance().tintColor = UIColor.whiteColor()

// In map viewcontroller viewDidLoad 
self.edgesForExtendedLayout = UIRectEdge.None
self.navigationController?.navigationBar.translucent = false

给出了相同的结果。

请帮助我了解最新情况。

2 个答案:

答案 0 :(得分:4)

我发现了什么问题..........在设置中,在General / Accessibility / Increase Contrast下有一个选项叫做Darker colors ...我打开了那个使色彩变暗的颜色(当然)。太傻了。

答案 1 :(得分:0)

这很可能是由于顶部NavigationBar的alpha(透明度)开启。当内容在顶部栏下方滑动时,它会显示基础视图的百分比,导致您的白人不是白色。

您可以通过关闭NavigationBar上的透明度来消除此问题:

self.navigationController.navigationBar.translucent = NO;

或通过设置阻止内容在栏下滚动:

edgesForExtendedLayout = UIRectEdgeNone;

有关详细信息以及扩展布局和透明导航栏的说明,请参阅此StackOverflow answer