Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change navigation bar tint color iOS 7.

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.

like image 697
Mayank Purwar Avatar asked Nov 10 '13 16:11

Mayank Purwar


People also ask

Can you change Iphone navigation bar?

Change the Bar StyleA user changes the navigation bar's style, or UIBarStyle , by tapping the “Style” button to the left of the main page. This button opens an action sheet where users can change the background's appearance to default, black-opaque, or black- translucent.

How do I darken my navigation bar?

Tap on the settings cog next to the static color icon — this brings up a color wheel to choose your desired shade. Select black for your saturation and zero opacity, then tap on Select This color . You should notice your nav bar turn black at this point.

How do I change my Apple navigation bar?

On your Mac, use Dock & Menu Bar System Preferences to change the appearance of the Dock, and to select items to show in the menu bar and in Control Center. To change these preferences, choose Apple menu > System Preferences, then click Dock & Menu Bar .


2 Answers

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]];
}
like image 186
Tarek Hallak Avatar answered Sep 20 '22 03:09

Tarek Hallak


you can add bellow code in appdelegate.m

  if your app is navigation based

 // for background color
  [nav.navigationBar setBarTintColor:[UIColor blueColor]];

 // for change navigation title and button color
[[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary    dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName,  [UIFont fontWithName:@"FontNAme" size:20], NSFontAttributeName, nil]];

[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
like image 42
Hitesh Vaghela Avatar answered Sep 18 '22 03:09

Hitesh Vaghela