Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6224139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:37:11+00:00 2026-05-24T08:37:11+00:00

In my app I am overriding the uinavigationbar color in the AppDelegate to create

  • 0

In my app I am overriding the uinavigationbar color in the AppDelegate to create this color across the entire app:

@implementation UINavigationBar (UINavigationBarCategory)

- (void)drawRect:(CGRect)rect {

UIColor *color = [UIColor colorWithRed:0.16
                                 green:0.20
                                  blue:0.32
                                 alpha:1];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColor(context, CGColorGetComponents( [color CGColor]));
CGContextFillRect(context, rect);
[self setBarStyle:UIBarStyleBlack];
[self setTintColor:color];


}

However, in one of my views, i would like to change the color of one of the nav bar items to another color, different from the global color above, but only for one of the items – the bar color should stay the same (reasoning – i’d like to have a nav bar item in green and a “On” text and change it to red with an “Off” text based on the user input).

I tried to override the color of the button in my view in the following way, but it doesnt seem to do anything.

- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
    [self.navigationController.navigationBar setTintColor:[UIColor greenColor]];
}

Does anyone have a suggestion (or a better way) to make this happen?

Cheers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:37:12+00:00Added an answer on May 24, 2026 at 8:37 am

    It is tested code which will work 100%.

    //in below code u can set the different image for different color

    or

    simply

    fill the color by your question code.

    here below is for put image in navigation bar

    u can customize by removeing the picture code and puttting ur above code with different color.that it .logic is same

    CustomNavigation.h

        #import <Foundation/Foundation.h>
    
    
        @interface UINavigationBar (UINavigationBarCustomDraw){
    
        }
    
        @end
    

    CustomNavigation.m

        @implementation UINavigationBar (UINavigationBarCustomDraw)
    
        - (void) drawRect:(CGRect)rect {
    
            [self setTintColor:[UIColor colorWithRed:0.5f
                                               green: 0.5f
                                                blue:0 
                                               alpha:1]];
    
            if ([self.topItem.title length] > 0) {
    
    
                if ([self.topItem.title isEqualToString:@"First"]) {
    
                    [[UIImage imageNamed:@"First.png"] drawInRect:rect];
    
                }
    
                else if ([self.topItem.title isEqualToString:@"Second"]) {
    
                    [[UIImage imageNamed:@"Second.png"] drawInRect:rect];                   
    
                }
    
    
    
    
                CGRect frame = CGRectMake(0, 0, 320, 44);
                UILabel *label = [[[UILabel alloc] initWithFrame:frame] autorelease];
                [label setBackgroundColor:[UIColor clearColor]];
                label.font = [UIFont boldSystemFontOfSize: 20.0];
                label.shadowColor = [UIColor colorWithWhite:0.0 alpha:1];
                label.textAlignment = UITextAlignmentCenter;
                label.textColor = [UIColor whiteColor];
                label.text = self.topItem.title;
                self.topItem.titleView = label;
    
    
    
    
    
            } 
    
    
            else {
                [[UIImage imageNamed:@"wood.png"] drawInRect:rect];
                self.topItem.titleView = [[[UIView alloc] init] autorelease];
            }
    
    
    
        }
    
        @end
    

    if u want to First.png to set navigationBar background image in FirstViewController then

    in ur FirstViewController.m

            -(void) viewWillAppear:(BOOL)animated{
    
            [super viewWillAppear:animated];
    
    
    
                self.title=@"First";
                [self.navigationController.navigationBar drawRect:CGRectMake(0, 0, 320, 480)];
    
        }
    

    if u want to Second.png to set navigationBar background image in SecondViewController then

    in ur SecondViewController.m

            -(void) viewWillAppear:(BOOL)animated{
    
            [super viewWillAppear:animated];
    
    
    
                self.title=@"Second";
                [self.navigationController.navigationBar drawRect:CGRectMake(0, 0, 320, 480)];
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am overriding the onBackPressed method in my app : public void onBackPressed() {
Just wanted to know if overriding UITabBarController would get my app rejected? Is it
I have UITableViewController (initiated by the Navigation-based app project template). I am overriding loadView
I've defined some models in App.run below which I'm overriding within the controller someCtrl
In my ASP.NET MVC app, I'm handling errors by overriding OnException in the controller.
I upgraded a Rails 3.0 app to Rails 3.1 which involved putting this /*
I'm overriding the OnStartup method as below within my App.xaml.cs. However, once I added
I want to create a rails app using Test-Driven Development (TDD), so i wrote
I'm overriding the touches methods in a UIView for a piano app. If I
I have some great troubles overriding some functions in an external App that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.