Swift 3.0 Adding a Right Button to Navigation Bar

前端 未结 6 953
夕颜
夕颜 2020-12-29 04:00

I have added a navigation bar to the top of a view controller. I am trying to control whether a button is visible based a condition, but I am having trouble adding the butto

6条回答
  •  梦毁少年i
    2020-12-29 04:34

    let rightBarButtonItem = UIBarButtonItem.init(image: UIImage(named: "EditImage"), style: .done, target: self, action: #selector(ViewController.call_Method))
    
    self.navigationItem.rightBarButtonItem = rightBarButtonItem
    

提交回复
热议问题