It is very much possible to convert the RGBA values to UIColor, you don't have to keep using standard [UIColor redColor] or [UIColor greenColor]. You can create your own color with your own RGB values.
Note: The value of red, green,blue and alpha will be between 0 and 1. Also if you can reduce the value of alpha to be something like 0.3 or 0.5 as long as it is between 0 and 1, to manipulate the transparency.
CGFloat nRed=128.0/255.0;
CGFloat nBlue=98.0/255.0;
CGFloat nGreen=53.0/255.0;
UIColor *myColor=[[UIColor alloc]initWithRed:nRed green:nBlue blue:nGreen alpha:1];Note: The value of red, green,blue and alpha will be between 0 and 1. Also if you can reduce the value of alpha to be something like 0.3 or 0.5 as long as it is between 0 and 1, to manipulate the transparency.
Just noticed a mistake in your sample. When you set nBlue you need to set it to 98.0/255.0 (yours is just 98). Otherwise it will be interpreted as 0 and throw off your color.
ReplyDeleteThanks !
ReplyDeleteFixed it.
CGFloat nRed=25.0/255.0;
ReplyDeleteCGFloat nGreen=34.0/255.0;
CGFloat nBlue=53.0/255.0;
UIColor *myColor=[[UIColor alloc]initWithRed:nRed green:nGreen blue:nBlue alpha:1];
more user friendly if you can change above ..