我试图获取一个按钮的文本,在点击时将字体颜色更改为红色.我查看了几个月前的类似帖子,使用该代码会导致Xcode 6.1.1中出现构建错误.这是我正在尝试的代码:
class ViewController: UIViewController {
@IBAction func firstButton(sender: UIButton) {
firstButton.titleLabel.textColor = UIColor.redColor()
}
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误代码是:
'(UIButton) - >()'没有名为'titleLabel'的成员
任何帮助将非常感激,因为我在尝试学习Objective C后失去耐心,因此我认为Swift是我的拯救恩典.