UIColor does not match RGB

I have an image in Fireworks. I use the picker to select a color and then look at the RGB values. I put these values ​​in UIColor:colorWithRed:green:blue:alpha , but this does not give me the same result. I use values ​​between 1.0 and 0.0.

I'm trying to get a dark blue color, UIColor gives me a very light blue.

Ideas?

+4
source share
4 answers

It seems to me that your calculations for converting the value from the fireworks to the value needed in UIColor are disabled.

example:

Fireworks RGB Values ​​Red: 64 Green: 87 Blue: 188

divide these three numbers by 255

gives you [UIColor colorWithRed:0.250980392156863 green:0.341176470588235 blue:0.462745098039216 alpha:1.0]

+10
source

Add this to the header file: (something like helpers.h)

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

Then add this to YourApp_Prefix.pch

 #import "helpers.h" 

Finally, when you need color, you should use this:

 UIColor* myColor = RGBCOLOR(64,87,188); 
+7
source

Make sure you retrieve the float values, including the decimal points in your statement.

 UIColor *myColor = [UIColor colorWithRed:16.0/255 green:176.0/255 blue:230.0/255 alpha:1]; 

Hope this helps.

0
source
 #define UIColorFromRGBWithAlpha(rgbValue,a) [UIColor \ colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \ green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \ blue:((float)(rgbValue & 0xFF))/255.0 alpha:a] 

define kbackGroundColor UIColorFromRGB (0x00A99D)

use this code with the best of RGB on sixteenth color .... Greetings

0
source

Source: https://habr.com/ru/post/1302283/


All Articles