tag:blogger.com,1999:blog-7756992915224554856.post7265262543705828903..comments2022-03-22T14:44:04.529-04:00Comments on Cocoa-Matic: UIColor macro with hex valuestkhttp://www.blogger.com/profile/06390051897876600373noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-7756992915224554856.post-18355919897681708872013-06-14T05:38:10.870-04:002013-06-14T05:38:10.870-04:00For those who want to do it as a category of UICol...For those who want to do it as a category of UIColor<br /><br />@implementation UIColor (Hex)<br /><br />//RGB color with alpha<br />+ (UIColor *)colorWithHex:(int)hexValue alpha:(CGFloat)alpha<br />{<br /> return [UIColor<br /> colorWithRed:((float)((hexValue & 0xFF0000) >> 16))/255.0<br /> green:((float)((hexValue & 0xFF00) >> 8))/255.0<br /> blue:((float)(hexValue & 0xFF))/255.0 alpha:alpha];<br />}<br /><br /><br />//RGB color<br />+ (UIColor *)colorWithHex:(int)hexValue<br />{<br /> return [UIColor colorWithHex:hexValue alpha:1.0];<br />}<br /><br />@endallbtohttps://www.blogger.com/profile/13594798720081705512noreply@blogger.comtag:blogger.com,1999:blog-7756992915224554856.post-66386476048394394462012-04-04T16:13:48.520-04:002012-04-04T16:13:48.520-04:00Thank you for this!!! Exactly what I've been ...Thank you for this!!! Exactly what I've been looking for!scotts7777https://www.blogger.com/profile/15890029041184853865noreply@blogger.comtag:blogger.com,1999:blog-7756992915224554856.post-18589711229754270972011-07-30T17:46:51.878-04:002011-07-30T17:46:51.878-04:00Your macros for UIColor from hex rgb values might ...Your macros for UIColor from hex rgb values might be handy as a category on UIColor that could be used as follows:<br /><br />UIColor* color = [UIColor colorFromHexRGB:0xFF00FF];<br /><br />and<br /><br />UIColor* colorWithAlpha = [UIColor colorFromHexRGBA:0xFF00FF88];Theohttps://www.blogger.com/profile/05122089194681636361noreply@blogger.comtag:blogger.com,1999:blog-7756992915224554856.post-9095722451385411492010-11-27T06:40:43.241-05:002010-11-27T06:40:43.241-05:00Absolutely brilliant!
Thanks a lot!
NachoAbsolutely brilliant!<br />Thanks a lot!<br />NachoIgnacio Pascualhttps://www.blogger.com/profile/10519996329548139017noreply@blogger.com