简体   繁体   中英

RGB color codes not showing color in iphone app

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 ];

colorWithRed:green:blue:alpha的参数是0到1之间的浮点值。因此,您必须将所有数字除以255,例如:

color = [UIColor colorWithRed:1.0f green:0.75f blue:0f alpha:1f];

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

iOS上的RGB值仅介于0和1之间,因此您必须将所需的色相除以255.0f如下所示:

UIColor *color=[UIColor colorWithRed:255.0f/255.0f green:192.0f/255.0f blue:0.0f alpha:0.0f];

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM