Search code examples
iosobjective-cbackground-colornavigationbar

Navigation bar color not setting properly


Why is the navigation bar color coming so weired? Why is it white above and only a bit red at the bottom. I cannot make out if the status bar is overlapping my navigation bar or what. This is the code I used to change the color of the navigation bar background:

    [navbar setBackgroundColor:[UIColor redColor]];


Solution

  • Solution

    [navbar setBarTintColor:[UIColor redColor]];
    [navbar setTranslucent:NO];
    

    Why

    The color of a UINavigationBar is set with its barTintColor property.

    What you're seeing is the translucent white navigation bar above your red background. The bit at the bottom is where UINavigationBar renders a shadow below the bar view.