Pregunta

When I call

[[UINavigationBar appearance] setBarTintColor:[UIColor greenColor]];

in

didFinishLaunchingWithOptions

All works fine, but the following code gives white color:

[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:21.0 green:194.0 blue:179.0 alpha:0.5]];

I can't understand why. NavBar translucent is enabled.

¿Fue útil?

Solución

[UIColor colorWithRed:21.0 green:194.0 blue:179.0 alpha:0.5]

You're creating your UIColor wrong - for each parameter needed to create a UIColor, a value between 0.0 and 1.0 is accepted. To get these, you divide your RGB values by 255:

[UIColor colorWithRed:21.0/255.0 green:194.0/255.0 blue:179.0/255.0 alpha:0.5]
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top