You can easily create a UIColor
from a hex color string in Swift using an extension on UIColor
. Here's the code for the extension:
main.swift891 chars28 lines
To use this extension, simply create a new UIColor
instance using the hexString
parameter:
main.swift44 chars2 lines
This will create a new UIColor
instance with the red color #FF0000 (equivalent to UIColor.red).
gistlibby LogSnag