Search code examples
iosreact-nativeuikituicolor

iOS Background Colour - Solid


I am trying to change the iOS background colour, however i believe transparency (alpha:1) seems to be having an effect and altering the intended colour.

In **AppDelegate.m**

  rootView.backgroundColor = [[UIColor alloc] initWithRed:.44f green:.41f blue:.52f alpha:1];

If i set Alpha to 0, i get black. With Alpha set to 1, and i get a blue/grey. I would like a solid colour, represented by the following HEX and/or RGB value.

#292C34

or

rgb(41,44,52)

Thanks,


Solution

  • if you set the alpha to 0 then the color is completely transparent, which is why you see black. What you want to do is get the decimal value by dividing by 255.

    rootView.backgroundColor = [[UIColor alloc] initWithRed:(44.0f/255.0f) green:(41.0f/255.0f) blue:(52.0f/255.0f) alpha:1]