Changing text of UIButton programmatically swift

后端 未结 11 1493
天命终不由人
天命终不由人 2020-11-28 19:34

Simple question here. I have a UIButton, currencySelector, and I want to programmatically change the text. Here\'s what I have:

currencySelector.text = \"foo         


        
11条回答
  •  野性不改
    2020-11-28 20:19

    In Swift 3, 4, 5:

    button.setTitle("Button Title", for: .normal)
    

    Otherwise:

    button.setTitle("Button Title", forState: UIControlState.Normal)
    

    Also an @IBOutlet has to declared for the button.

提交回复
热议问题