How to add custom view on right of navigation bar Swift?

前端 未结 6 1545
猫巷女王i
猫巷女王i 2020-12-16 21:59

I am trying to add a custom view on right of UINavigationBar. What I tried is the following, but the view is not showing up! Pleas

6条回答
  •  隐瞒了意图╮
    2020-12-16 22:19

    I add this code in viewWillAppear(), and work for me

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.navigationController?.navigationBar.isHidden = false
        self.navigationItem.title = "Forgot Password?"
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView:UIImageView(image: UIImage(named: "btn_back")))
    }
    

提交回复
热议问题