change text of button and disable button in iOS

后端 未结 8 910
Happy的楠姐
Happy的楠姐 2020-12-23 12:52

How do you change the text of the button and disable a button in iOS?

8条回答
  •  北荒
    北荒 (楼主)
    2020-12-23 13:31

    If somebody, who is looking for a solution in Swift, landed here, it would be:

    myButton.isEnabled = false // disables
    myButton.setTitle("myTitle", for: .normal) // sets text
    

    Documentation: isEnabled, setTitle.

    Older code:

    myButton.enabled = false // disables
    myButton.setTitle("myTitle", forState: UIControlState.Normal) // sets text
    

提交回复
热议问题