How To Set UILabel Color In Swift Programmatically

By Eddy Chung

Change the color of your label in code.

How To Set UILabel Color In Swift Programmatically

If you know your RGB values you can simply set the background color by doing:

label.textColor = UIColor(red: 1.00, green: 1.00, blue: 1.00, alpha: 1.00)

You can also convert a HEX color to UIColor by using these tools:

You can also use the standard UIColors such as:

label.textColor = UIColor.green

Here’s a full list of UIColors

If you liked this post, you'll love my free guide: Secrets To iOS Development. Speed up your learning curve - hundreds of students have already downloaded. Thanks for reading!
Profile Picture of Eddy Chung

Eddy Chung

I am a professional iOS developer in Silicon Valley. I teach iOS development on ZeroToAppStore.com. If you'd like to learn more about me click here or you can contact me at: eddy@zerotoappstore.com

Similar Posts