sky*_*guy 23 uibutton ios swift
我知道如何更改背景颜色,但实际文本呢?UIButton上似乎没有成员称为"颜色"或类似的东西.我的代码:
@IBAction func yellowBtnClicked(sender: UIButton) {
gameboard.image = UIImage(named: "Yellow_gb")
resultsView.image = UIImage(named: "Yellow_results")
colorsView.image = UIImage(named: "Yellow_colors")
colorsBtn.color = UIColor.brownColor() //This line has the issue
}
Run Code Online (Sandbox Code Playgroud)
cod*_*ter 59
没有的属性设置color在UIButton.改为使用.setTitleColor写入viewWillAppear
colorsBtn.setTitleColor(UIColor.brownColor(), forState: UIControlState.Normal)
Run Code Online (Sandbox Code Playgroud)
这会将标题颜色更改为棕色 UIControlState.Normal
设置title按钮处于Highlighted状态时的颜色
colorsBtn.setTitleColor(UIColor.brownColor(), forState: UIControlState.Highlighted)
Run Code Online (Sandbox Code Playgroud)
Swift 3.0示例:
colorsBtn.setTitleColor(UIColor .white, for: UIControlState.normal)
colorsBtn.setTitleColor(UIColor .black, for: UIControlState.highlighted)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
39519 次 |
| 最近记录: |