Changing text of UIButton programmatically swift

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

    To set a title for a button in Xcode using swift - 04: first create a method called setTitle with parameter title and UIController state like below ;

    func setTitle(_ title : String?, for state : UIControl.State)   {
    
    }
    

    and recall this method in your button action method like ;

    yourButtonName.setTitle("String", for: .state)
    

提交回复
热议问题