[英]How to change the color of the button title in Swift
是否可以更改按钮标题的颜色?
因为这段代码不起作用
btnLogin.titleColor = UIColor.darkGray
尝试这个:
btnLogin.setTitleColor(.red, for: .normal)
正如其他评论所说,使用
btnLogin.setTitleColor(UIColor.darkGray, for: .normal)
在这里您可以阅读此方法的说明和不同状态(正常、选中、突出显示、...)
https://developer.apple.com/documentation/uikit/uibutton/1623993-settitlecolor
你可以这样设置:
button.setTitleColor(.blue, for: .normal)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.