NavigationBar bar, tint, and title text color in iOS 8

前端 未结 18 2320
星月不相逢
星月不相逢 2020-12-02 04:08

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         


        
18条回答
  •  心在旅途
    2020-12-02 04:48

    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 = [NSAttributedString.Key.foregroundColor : UIColor.white]
    

    (For Swift 4 or earlier use NSAttributedStringKey instead of NSAttributedString.Key)

    For titleTextAttributes, the docs say:

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

提交回复
热议问题