Changing text of UIButton programmatically swift

后端 未结 11 1498
天命终不由人
天命终不由人 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:16

    Swift 3

    When you make the @IBAction:

    @IBAction func btnAction(_ sender: UIButton) {
      sender.setTitle("string goes here", for: .normal)
    }
    

    This sets the sender as UIButton (instead of Any) so it targets the btnAction as a UIButton

提交回复
热议问题