skip to Main Content

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.

2

Answers


  1. You can try this way:

    labelname.backgroundColor = UIColor.red
    

    or

    labelname.backgroundColor = UIColor(red:0, green:159.0/255.0, blue:184.0/255.0)
    
    Login or Signup to reply.
  2. As aheze wrote in the comment, I used UIColor(named: "YourColorNameHere")

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search