UINavigationBar 和 UITabbar tintColor 在 iPhone6Plus 中不起作用
UINavigationBar & UITabbar tintColor not working in iPhone6Plus
我正在使用 Swift2 和 Xcode7 开发 iOS 应用程序。我想更改 UINavigationBar 和 UITabbar tintColor,所以我在 AppDelegate.swift.
中编写了以下代码
UINavigationBar.appearance().barTintColor = UIColor.appThemeColor()
UINavigationBar.appearance().titleTextAttributes = [
NSForegroundColorAttributeName:UIColor.blackColor(),
NSFontAttributeName:UIFont.systemFontOfSize(20.0)
]
UINavigationBar.appearance().tintColor = UIColor.whiteColor()
UITabBarItem.appearance().setTitleTextAttributes([
NSForegroundColorAttributeName:UIColor.whiteColor(),
NSFontAttributeName:UIFont.boldSystemFontOfSize(12.0)
], forState: UIControlState.Selected)
UITabBarItem.appearance().setTitleTextAttributes([
NSFontAttributeName:UIFont.boldSystemFontOfSize(12.0)
], forState: UIControlState.Normal)
UITabBar.appearance().tintColor = UIColor.whiteColor()
UITabBar.appearance().barTintColor = UIColor.appThemeColor()
但是只有iPhone6plus(iOS8.1)的tabbar selected icon和navigation bar icon的颜色不是白色而是浅灰色。在iPhone6S(iOS9.0)和iPhone5(iOS8.4)中,都可以正常使用。你知道原因吗?
转到 Settings
> General
> Accessibilty
> Increase Contrast
并关闭 Darken Colors
.
检查this answer。
我正在使用 Swift2 和 Xcode7 开发 iOS 应用程序。我想更改 UINavigationBar 和 UITabbar tintColor,所以我在 AppDelegate.swift.
中编写了以下代码UINavigationBar.appearance().barTintColor = UIColor.appThemeColor()
UINavigationBar.appearance().titleTextAttributes = [
NSForegroundColorAttributeName:UIColor.blackColor(),
NSFontAttributeName:UIFont.systemFontOfSize(20.0)
]
UINavigationBar.appearance().tintColor = UIColor.whiteColor()
UITabBarItem.appearance().setTitleTextAttributes([
NSForegroundColorAttributeName:UIColor.whiteColor(),
NSFontAttributeName:UIFont.boldSystemFontOfSize(12.0)
], forState: UIControlState.Selected)
UITabBarItem.appearance().setTitleTextAttributes([
NSFontAttributeName:UIFont.boldSystemFontOfSize(12.0)
], forState: UIControlState.Normal)
UITabBar.appearance().tintColor = UIColor.whiteColor()
UITabBar.appearance().barTintColor = UIColor.appThemeColor()
但是只有iPhone6plus(iOS8.1)的tabbar selected icon和navigation bar icon的颜色不是白色而是浅灰色。在iPhone6S(iOS9.0)和iPhone5(iOS8.4)中,都可以正常使用。你知道原因吗?
转到 Settings
> General
> Accessibilty
> Increase Contrast
并关闭 Darken Colors
.
检查this answer。