Swift Custom NavBar Back Button Image and Text

后端 未结 12 1518
谎友^
谎友^ 2021-01-30 10:40

I need to customise the look of a back button in a Swift project.

Here\'s what I have:

Here\'s what I want:

I\'ve tried creating my own UIBarButtonItem

12条回答
  •  逝去的感伤
    2021-01-30 10:41

    I have tried all the above and all make the custom image without changing the text The only one worked for me is from this answer

    let backBTN = UIBarButtonItem(image: UIImage(named: "Back"), 
                                  style: .plain, 
                                  target: navigationController, 
                                  action: #selector(UINavigationController.popViewController(animated:)))
    navigationItem.leftBarButtonItem = backBTN
    navigationController?.interactivePopGestureRecognizer?.delegate = self
    

提交回复
热议问题