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 convert a HEX color value like “#808080”(grey hex color code) to UIColor in Swift.
Most designers and color pickers are working with hex color values, but there is no builtin conversion from a hex string to 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.
Learn how to create a visually appealing website or app by selecting the right color palette. Discover the importance of color psychology, researching your brand and audience, and using the color wheel and color theory.
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