Color Helper – Objective C

I got some Color Helper which was much useful for me to just simply set the RGB color code in the UI Fields in UIKit

here what i get …

#define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1]

#define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 \alpha:(a)]

#define HSVCOLOR(h,s,v) [UIColor colorWithHue:(h) saturation:(s) value:(v) alpha:1]

#define HSVACOLOR(h,s,v,a) [UIColor colorWithHue:(h) saturation:(s) value:(v) alpha:(a)]

#define RGBA(r,g,b,a) (r)/255.0, (g)/255.0, (b)/255.0, (a)

Simply put the above four in ur .pch file or any other file (make sure you import  it to use this Helper Methods)

i grab this code from three20

Now using this you just need to set color as

view.setBackgroundColor = RGBCOLOR(40, 35, 56);

RGBACOLOR can be used to set color along with View’s alpha .. RGBACOLOR(40, 35, 56, 0.6) fourth parameter (0.6) will be for alpha in this case

Hope this help others a Lot !!


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s