小编coo*_*mac的帖子

如何设置UIButton的标题文本颜色?

我尝试更改按钮的文本颜色,但它仍然保持白色.

isbeauty = UIButton()
isbeauty.setTitle("Buy", forState: UIControlState.Normal)
isbeauty.titleLabel?.textColor = UIColorFromRGB("F21B3F")
isbeauty.titleLabel!.font = UIFont(name: "AppleSDGothicNeo-Thin" , size: 25)
isbeauty.backgroundColor = UIColor.clearColor()
isbeauty.layer.cornerRadius = 5
isbeauty.layer.borderWidth = 1
isbeauty.layer.borderColor = UIColorFromRGB("F21B3F").CGColor
isbeauty.frame = CGRectMake(300, 134, 55, 26)
isbeauty.addTarget(self,action: "first:", forControlEvents: UIControlEvents.TouchUpInside)
self.view.addSubview(isbeauty)
Run Code Online (Sandbox Code Playgroud)

我也试过把它改成红色,黑色,蓝色,但什么也没发生.

uibutton ios swift

106
推荐指数
3
解决办法
10万
查看次数

标签 统计

ios ×1

swift ×1

uibutton ×1