How to give Hex color to Labels or Background Image

Hi


How we can give HexColor (5437e) or some other HexColor to Labels,Texts or Background. Controls have been created on Storyboard itself.


Thanks

Answered by Claude31 in 243074022

Here is how to do in code : convert the hex into its 3 components color to get a UIColor and set the alphavalue :


h ttps://stackoverflow.com/questions/24263007/how-to-use-hex-colour-values-in-swift-ios


Then set the color of the object to the UIColor using the extension

label.layer.backgroundColor = UIColor(myHexColor)
Accepted Answer

Here is how to do in code : convert the hex into its 3 components color to get a UIColor and set the alphavalue :


h ttps://stackoverflow.com/questions/24263007/how-to-use-hex-colour-values-in-swift-ios


Then set the color of the object to the UIColor using the extension

label.layer.backgroundColor = UIColor(myHexColor)
How to give Hex color to Labels or Background Image
 
 
Q