Eugene Belinski profile pictureEugene Belinski

he / him

UIHex: a new tool to instantly convert hex code to UIColor

One of the most monotonous tasks I come across while developing iPhone and iPad apps is converting web colors, also known as hex codes, into instances of UIColor. In iOS applications, a UIColor object is the most common way of representing a particular color. Unfortunately, there is no built-in method to convert a hex code into a UIColor instance. The developer must supply the RGB values for each UIColor, which can be tedious and can slow down development. There are various websites out there that let you convert hex codes into UIColor code snippets, but from what I’ve found, they have varying limitations. Some don’t supply the code snippet in Swift, Apple’s new programming language, while others are generally difficult to use. I decided to try to create my own tool.

The result, UIHex, is a simple online tool that instantly converts any hex code into UIColor code snippets for Swift and Objective-C. The tool is released under the GNU GPL license, and the code is viewable here. It was written in Javascript/jQuery.

If you like it, please let me know! Feel free to send me any comments, suggestions, or bugs by email or Twitter.