A navigation bar appears at the top of an app screen, below the status bar. Navigation bar contains the navigation buttons of a navigation controller, which is a stack of view controllers which can be pushed and popped.
Let’s do something with Navigation bar
-
Hide navigation bar
[self.navigationController setNavigationBarHidden:YES animated:YES];
-
Change navigation bar color
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
-
Change navigation tint color
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
-
Change navigation bar Title
self.navigationItem.title = @"This is title text";
-
Change navigation bar title color
[self.navigationController.navigationBar setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], NSForegroundColorAttributeName, [UIFont fontWithName:@"HelveticaNeue-Light" size:18.0], NSFontAttributeName, nil]];
-
Hide back text from back button
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
-
Hide back button
[self.navigationItem setHidesBackButton:YES animated:YES];
-
Add left button with Image
UIImage *image = [[UIImage imageNamed:@"menu.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(menuBtnClicked:)]; self.navigationItem.leftBarButtonItem = button;
-
Add right button
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addBtnAction:)]; self.navigationItem.rightBarButtonItem = addButton;
That’s It. If you like this post, Please comment below and subscribe this blog.