Learn how to use a HEX color string like “#808080”(grey hex color code) in Swift with UIColor.
In this article, we will learn how to use a HEX color string like “#808080”(grey hex color code) in Swift with UIColor.
Most designers and color pickers are working with hex color values, but there is no builtin conversion from a hex string to a UIColor. Let’s dive in and create a UIColor Swift extension that you can use to paste hex values directly into your swift code.
We will create a failable initializer, which will return nil if you specify a color in the wrong format.
The hex string should start with ‘#’ character and have red, green, blue and alpha components.
Now you can easily use this function to initialize UIColor with a hex color value.
We don’t just convert colors. Oh, no. We have the powerful color editing software you will ever need. If you need to pick a color from the screen, we can help you with that. If you need to generate a visually pleasing color palette, we can help you with that too. It’s not a problem, with Pikka.Download now