使用 swift 语言更改按钮背景颜色 [英] Change button background color using swift language
本文介绍了使用 swift 语言更改按钮背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是 swift 语言的新手.有人能告诉我如何使用 swift 语言更改按钮的背景颜色吗?
I am new to the swift language. Can someone tell me how to change the background color of a button using the swift language?
推荐答案
button.backgroundColor = UIColor.blue
或任何其他颜色:red
、green
、yellow
等
Or any other color: red
, green
, yellow
,etc.
另一个选项是 RGBA 颜色:
Another option is RGBA color:
button.backgroundColor = UIColor(red: 0.4, green: 1.0, blue: 0.2, alpha: 0.5)
这篇关于使用 swift 语言更改按钮背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文