我试图在按钮被点击时将按钮的文本颜色更改为红色。我查看了几个月前的类似帖子,并尝试使用其中的代码,但会导致Xcode 6.1.1中的构建错误。这是我正在尝试的代码:
class ViewController: UIViewController {
@IBAction func firstButton(sender: UIButton) {
firstButton.titleLabel.textColor = UIColor.redColor()
}
}
我收到的错误代码是:
'(UIButton) -> ()' 没有名为 'titleLabel' 的成员
非常感谢任何帮助,因为在尝试学习Objective C后失去耐心,我将Swift视为我的救星。