Changing UIButton text

后端 未结 7 1435
遇见更好的自我
遇见更好的自我 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:11

    For Swift 2.0:

    let btnObject : UIButton  = UIButton() 
    btnObject.frame = CGRect(x: 8, y: 89, width: 70, height: 22)
    btnObject.setTitle("Button Title", forState: UIControlState.Normal)
    btnObject.titleLabel?.font = UIFont(name: "Helvetica Neue", size: 13)
    btnObject.titleLabel?.textColor = UIColor.whiteColor()
    btnObject.backgroundColor = UIColor(red: 189/255, green: 176/255, blue: 0/255, alpha: 1)
    btnObject.titleLabel?.textAlignment = NSTextAlignment.Center
    btnObject.addTarget(self, action: "btnbtnObjectClick:", forControlEvents: UIControlEvents.TouchUpInside)
    subView.addSubview(btnObject)
    

提交回复
热议问题