Hex code for clear color
15,645
Solution 1
UIColor *clearColor = [UIColor clearColor];
CGFloat red = 0;
CGFloat green = 0;
CGFloat blue = 0;
CGFloat alpha = 0;
[clearColor getRed:&red green:&green blue:&blue alpha:&alpha];
NSLog(@"red: %.3f, green: %.3f, blue: %.3f, alpha: %.3f",
red, green, blue, alpha);
NSLog(@"red: 0x%02x, green: 0x%02x, blue: 0x%02x, alpha: 0x%02x",
(int)(red*255.0), (int)(green*255.0), (int)(blue*255.0), (int)(alpha*255.0));
NSLog output:
red: 0.000, green: 0.000, blue: 0.000, alpha: 0.000
red: 0x00, green: 0x00, blue: 0x00, alpha: 0x00
Solution 2
RGBA Hex Code for ClearColor:
NNNNNN00
whereas N may be any hex-value (0-F).
Solution 3
As far as I know, hexadecimal color codes are made up of RRGGBB values, whereas [UIColor clearColor]
depends very much on there being an alpha component.
So the answer is "nope", there's no hexa code for clearColor
.
Comments
-
iOS almost 2 years
My ques may be silly. Is there an hexa code for
[UIColor clearColor]
? If so, what is the code? Thanks in advance. -
Mattias Wadman over 12 yearsHmm i think alpha should be zero, did you test run it? when i do it outputs
red: 0.000, green: 0.000, blue: 0.000, alpha: 0.000
. -
zaph over 12 years@beryllium nice catch, I posted my test case result by accident, corrected.