UIColor Macro For ObjC

Declare in your app .pch

    #define rgb(R,G,B) [UIColor colorWithRed:R/255.0f green:G/255.0f blue:B/255.0f alpha:1.0]

    #define rgba(R,G,B,A) [UIColor colorWithRed:R/255.0f green:G/255.0f blue:B/255.0f alpha:A]

After that you can use like

mylabel.textColor = rgb(231, 76, 60);
myview.backgroundColor = rgba(231, 76, 60,0.2); 
// Alpaha value max is 1 and min is 0 , you must use float point
comments powered byDisqus