本文介绍了iOS 8中的NavigationBar栏,色调和标题文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
状态栏中的背景文字仍为黑色。如何将颜色更改为白色?
The background text in the status bar is still black. How do I change the color to white?
// io8, swift, Xcode 6.0.1
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.navigationBar.barTintColor = UIColor.blackColor()
self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.orangeColor()]
}
推荐答案
在 AppDelegate.swift
,在应用程序中(_:didFinishLaunchingWithOptions :)
我将以下内容添加:
In AppDelegate.swift
, in application(_:didFinishLaunchingWithOptions:)
I put the following:
UINavigationBar.appearance().barTintColor = UIColor(red: 234.0/255.0, green: 46.0/255.0, blue: 73.0/255.0, alpha: 1.0)
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor : UIColor.white]
对于 titleTextAttributes
,说:
这篇关于iOS 8中的NavigationBar栏,色调和标题文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!