Changing UIButton text

后端 未结 7 1438
遇见更好的自我
遇见更好的自我 2020-12-25 10:23

So I\'m trying to update the text on a UIButton when I click it. I\'m using the following line to change the text:

calibrationButton.titleLabel.text = @\"Cal         


        
7条回答
  •  情书的邮戳
    2020-12-25 11:08

    For Swift 3.0

    let button = UIButton(type: .system)
    button.frame = CGRect(x: 100, y: 100, width: 100, height: 100)
    button.setTitle("set here", for: .normal)
    button.addTarget(self, action: #selector(TableViewController.actionButtonTocuh), for: .touchUpInside)
    button.titleLabel?.textColor  = #colorLiteral(red: 0.1019607857, green: 0.2784313858, blue: 0.400000006, alpha: 1)
    view.addSubview(button)
    

提交回复
热议问题