how to change navigationitem title color

前端 未结 11 1423
南旧
南旧 2021-01-30 12:35

I think all day to change the navigation Bar title color, but it doesn\'t work. this is my code:

var user: User? {
    didSet {
        navigationItem.title = us         


        
11条回答
  •  野性不改
    2021-01-30 13:13

    Swift 4

    create project and test this with ViewController easy to use

    import UIKit
    class ProfileViewController: UIViewController {
          override func viewDidLoad() {
            super.viewDidLoad()
            configureNavigationBar()
              
              }
            func configureNavigationBar() {
                navigationItem.title = "Profile"
       let textChangeColor =[NSAttributedString.Key.foregroundColor:UIColor.black]
    navigationController?.navigationBar.titleTextAttributes = textAttributes
                  navigationItem.rightBarButtonItem?.tintColor = .white
                navigationItem.rightBarButtonItem = UIBarButtonItem(image: #imageLiteral(resourceName: "arrow_right").withRenderingMode(.alwaysOriginal), style: .plain, target: self, action: #selector(handleDismiss))
                  navigationController?.navigationBar.prefersLargeTitles = true
                navigationItem.rightBarButtonItem?.tintColor = .white
                        }
    }
    

提交回复
热议问题