【发布时间】:2015-12-20 10:10:31
【问题描述】:
我正在使用 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 的颜色和导航栏 icon 的颜色不是白色而是浅灰色。在 iPhone6S(iOS9.0) 和 iPhone5(iOS8.4) 中,一切正常。你知道原因吗?
【问题讨论】:
标签: ios iphone swift uinavigationbar uitabbar