Change navigation bar tint color iOS 7.

Mayank Purwar picture Mayank Purwar · Nov 10, 2013 · Viewed 24.3k times · Source

I know how to change navigation bat tint colour in iOS 6:

[UINavigationBar appearance].tintColor = [UIColor colorWithRed:129/255.0 green:200/255.0 blue:244/255.0 alpha:1.0];

I'm adding this code in APPDelegate page. Now I want to do this in iOS 7 but above code is not working. I searched on net. I got a solution. By adding below function to every page I can change navigation color.

self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:129/255.0 green:200/255.0 blue:244/255.0 alpha:1.0];

But I need a function which can add to APPDelegate function. Please help me to overcome this issue.

Answer

Tarek Hallak picture Tarek Hallak · Nov 11, 2013

Why not to use setBarTintColor for appearance proxy, you can do this:

if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) 
{
    [[UINavigationBar appearance] setTintColor: [UIColor colorWithRed:129/255.0 green:200/255.0 blue:244/255.0 alpha:1.0]];
}
else
{
    [[UINavigationBar appearance] setBarTintColor: [UIColor colorWithRed:129/255.0 green:200/255.0 blue:244/255.0 alpha:1.0]];
}