iOS: convert a HEX color to a UIColor method

Posted: November 17, 2014 in Apple, iOS
Tags:

The + colorWithRed:green:blue:alpha: method in UIColor requires color parameters as a value from 0.0 to 1.0, instead of the usual Hex or Decimal value.

It will be quite troublesome to convert those values (divide by 255 for each color component). Thanks for this link http://www.touch-code-magazine.com/web-color-to-uicolor-convertor/ http://uicolor.io/#/hex-to-ui or http://www.briangrinstead.com/blog/ios-uicolor-picker, it makes your life much easier by returning the Objective-c UIColor message directly.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s