How to use UIBarButtonSystemItem to change UIBarButtonItem identifier? (Swift)

前端 未结 5 1681
北恋
北恋 2021-01-02 06:43

I want to change the identifier of an UIBarButtonItem with codes from \"Play\" to \"Pause\". How can I do that?

Thanks

5条回答
  •  忘掉有多难
    2021-01-02 07:11

    I use this code to switch Edit mode

    @IBAction func editMode(sender: UIBarButtonItem) {
        self.setEditing(!self.isEditing, animated: true)
    
        let newButton = UIBarButtonItem(barButtonSystemItem: (self.isEditing) ? .done : .edit, target: self, action: #selector(editMode(sender:)))
        self.navigationItem.setLeftBarButton(newButton, animated: true)
    }
    

提交回复
热议问题