How to use a UIButton as a toggle switch

前端 未结 11 805
我在风中等你
我在风中等你 2020-12-02 18:44

I am using a UIButton of custom type and what I want is use it like a toggle switch with the change of image. Like when it is clicked if previously it was not in selected mo

11条回答
  •  感情败类
    2020-12-02 19:14

    For Swift 3

    @IBAction func playPause(sender : UIButton){
    
    
       if sender.isSelected {
          player.pause()
       }else{
          player.play()
      }
      sender.isSelected = !sender.isSelected
    }
    

提交回复
热议问题