Keep UIButton Selected/Highlighted after touch

后端 未结 5 1506
北荒
北荒 2020-12-24 15:14

I\'d like my button to remain highlighted after the user taps it. If the user taps the button again I\'d like it to become de-selected/unhighlighted. I\'m not sure how to go

5条回答
  •  长情又很酷
    2020-12-24 15:35

    Swift 5:

    @IBAction func toggleButton(_ sender: UIButton) {
        sender.isSelected = !sender.isSelected
    }
    

提交回复
热议问题