iOS 8中的NavigationBar栏,色调和标题文本颜色 [英] NavigationBar bar, tint, and title text color in iOS 8

查看:114
本文介绍了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 docs 说:


您可以为标题指定字体,文本颜色,文本阴影颜色和文本
阴影偏移量在文本属性字典中

You can specify the font, text color, text shadow color, and text shadow offset for the title in the text attributes dictionary

这篇关于iOS 8中的NavigationBar栏,色调和标题文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆