Search code examples
swiftxcodeuilabel

Swift How to set background color with custom color programmatically?


I am trying to change background color of a UILabel with a custom color programmatically.

Could anyone can tell me how to achieve this?

Thank you in advance.

EDIT

I would like to know how to use the color that is stored in Assets.xcassets folder.


Solution

  • As aheze wrote in the comment, I used UIColor(named: "YourColorNameHere")