Change button background color using swift language

kalim sayyad picture kalim sayyad · Jun 26, 2014 · Viewed 112.1k times · Source

I am new to the swift language. Can someone tell me how to change the background color of a button using the swift language?

Answer

nicael picture nicael · Jun 26, 2014
button.backgroundColor = UIColor.blue

Or any other color: red, green, yellow ,etc.

Another option is RGBA color:

button.backgroundColor = UIColor(red: 0.4, green: 1.0, blue: 0.2, alpha: 0.5)