Search code examples
iphoneobjective-ciosios4uicolor

Hex code for clear color


My ques may be silly. Is there an hexa code for [UIColor clearColor]? If so, what is the code? Thanks in advance.


Solution

  • 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