Reputation: 646
I am using RGB color code for my bar to show in iphone app but they don't show any color i am getting these code values from photoshop but when i use them they don't show any color in iphone app
For first line i have RGB code from photoshop is 255.192,0
color=[UIColor colorWithRed:255 green:192 blue:0 alpha:0 ];
For Second line i have RGB code from photoshop is 195,214,155
color=[UIColor colorWithRed:195 green:214 blue:155 alpha:0];
For Third line i have RGB code from photoshop is 49,133,156
color=[UIColor colorWithRed:49 green:133 blue:156 alpha:0 ];
Upvotes: 0
Views: 1645
Reputation: 1079
RGB values on iOS only fall between 0 and 1, so you must divide the hue you want by 255.0f
like
this:
UIColor *color=[UIColor colorWithRed:255.0f/255.0f green:192.0f/255.0f blue:0.0f alpha:0.0f];
Upvotes: 1
Reputation: 1723
Try setting your alpha value as 1 like this [UIColor colorWithRed:255/255 green:192/255 blue:0 alpha:1 ];'
alpha is the transparency of your color
Upvotes: 4
Reputation: 78825
The parameters of colorWithRed:green:blue:alpha
are floating point values between 0 and 1. So you have to divide all numbers by 255, e.g.:
color = [UIColor colorWithRed:1.0f green:0.75f blue:0f alpha:1f];
Upvotes: 4
Reputation: 1622
Change the line
color=[UIColor colorWithRed:255 green:192 blue:0 alpha:0 ];
to
color=[UIColor colorWithRed:(255/255.0) green:(192/255.0) blue:0 alpha:0 ];
I dont know about the alpha but I believe it should be 1
Upvotes: 1