Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Odd Conversion between UIColor and CGColor

So here are the colors I am trying to convert from UIColor to CGColor:

001385 - R:0 G:19 B:133

ca000b - R:202 G:0 B:11

Here is the Blue vs. iOS's rendering: a:enter image description here b:enter image description here

Here is the Red vs. iOS's rendering: a<code>enter image description here</code> b: enter image description here

Here is the code I am using to convert the colors: Red:

[[UIColor colorWithRed:202 green:0 blue:11 alpha:1] CGColor]

Blue:

[[UIColor colorWithRed:0 green:19 blue:133 alpha:1] CGColor]

Does anyone know what I am doing wrong?

like image 837
Jake Chasan Avatar asked Mar 17 '14 16:03

Jake Chasan


1 Answers

You need to divide the parameters by 255.0. As noted by @Duncan C, ensure you are dividing by 255.0

[[UIColor colorWithRed:202.0/255.0 green:0 blue:11/255.0 alpha:1] CGColor]


[[UIColor colorWithRed:0 green:19/255.0 blue:133/255.0 alpha:1] CGColor]
like image 141
jervine10 Avatar answered Sep 28 '22 08:09

jervine10