Search code examples
objective-cuicolor

How do I set UIColor to this exact shade green that I want?


I'm not sure what these codes are called, I think hex codes. The code for it is 006633 and it's a dark green color. I want it to match my view backgrounds.


Solution

  • For your problem:

    your Hex code #006633 stands for

    Red 00 Green 66 Blue 33

    Since they are in Hex, converting to int.

    R 0 ; G 102; B 51

    the iOS api set it as

     [self.view setBackgroundColor:[UIColor colorWithRed:0 green:102/255.0 blue:51/255.0 alpha:1.0]];
    

    Refere to the below links if you want to understand further

    How to convert HEX RGB color codes to UIColor?

    change the background color with code