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

  • Home
  • SEARCH
  • 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 7568369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:54:24+00:00 2026-05-30T14:54:24+00:00

I have code that changes the color of navigation bar using appearance attribute. I

  • 0

I have code that changes the color of navigation bar using appearance attribute. I would like the change to the navbar color to be visible immediately. However, I cannot find a proper call to make to redraw the navbar. Currently it’s color changes when I push a modal navigation controller, thus covering the navbar.

This does not work:

AppDelegate* appDelegate = ((AppDelegate*)[[UIApplication sharedApplication] delegate]);

    [appDelegate.window setNeedsDisplay];

I also tried asking various instances of navigation controller to redraw their views, which did not work.

What’s the correct way to ask the UINavigationBar to redraw itself on demand?

Thank you!

UPDATE: Here’s the code that works!

    - (UIColor *) colorOfPoint:(CGPoint)point
    {
        unsigned char pixel[4] = {0};
        CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
        CGContextRef context = CGBitmapContextCreate(pixel, 1, 1, 8, 4, colorSpace, kCGImageAlphaPremultipliedLast);

        CGContextTranslateCTM(context, -point.x, -point.y);

        [self.view.layer renderInContext:context];

        CGContextRelease(context);
        CGColorSpaceRelease(colorSpace);

        NSLog(@"pixel: %d %d %d %d", pixel[0], pixel[1], pixel[2], pixel[3]);
        float red = pixel[0]/255.0;
        float green = pixel[1]/255.0;
        float blue = pixel[2]/255.0;
        float alpha = pixel[3]/255.0;
        UIColor *color = [UIColor colorWithRed:red green:green blue:blue alpha:alpha];

        [[NSUserDefaults standardUserDefaults] setFloat:red forKey:@"navBarRed"];
        [[NSUserDefaults standardUserDefaults] setFloat:green forKey:@"navBarGreen"];
        [[NSUserDefaults standardUserDefaults] setFloat:blue forKey:@"navBarBlue"];    
        [[NSUserDefaults standardUserDefaults] setFloat:alpha forKey:@"navBarAlpha"];



        return color;
    }





  - (IBAction)handleTapFrom:(id)sender {

        if([sender isKindOfClass:[UITapGestureRecognizer class]])
        {


            CGPoint location = [tapGestureRecognizer locationInView:self.view];

            //remember color preferences
         UIColor* navbarColor =  [self colorOfPoint:location];
            selectColorView.center = location;

            //UPDATE THE NAVBAR COLOR CODE HERE

    //this does not update immediately 
        float navBarRed = [[NSUserDefaults standardUserDefaults] floatForKey:@"navBarRed"];
        float navBarGreen = [[NSUserDefaults standardUserDefaults] floatForKey:@"navBarGreen"];    
        float navBarBlue = [[NSUserDefaults standardUserDefaults] floatForKey:@"navBarBlue"];
        float navBarAlpha = [[NSUserDefaults standardUserDefaults] floatForKey:@"navBarAlpha"];

       UIColor* navBarColor =  [UIColor colorWithRed:navBarRed green:navBarGreen blue:navBarBlue alpha:navBarAlpha];


//set the color of all newly created navbars
        [[UINavigationBar appearance] setTintColor:navBarColor];  
        [[UINavigationBar appearance] setBarStyle:UIBarStyleBlackTranslucent];
        [[UINavigationBar appearance] setAlpha:0.7];


        //update the toolbar appearance
        [[UIToolbar appearance] setTintColor:navBarColor];

//set the color of the current navbar, displaying immediate change
self.navigationController.navigationBar.tintColor = navbarColor;



        }



    }
  • 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-30T14:54:27+00:00Added an answer on May 30, 2026 at 2:54 pm

    Can’t you just set the tintColor of the NavigationBar? That should work:

    self.navigationController.navigationBar.tintColor = [UIColor redColor];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a navigation bar/list that is using only HTML and CSS. The background
I have this code that changes the opacity of the div on hover. $(#navigationcontainer).fadeTo(slow,0.6);
I have some jQuery code that highlights a link when clicked, and changes the
Welcome, I notice that Youtube make some changes into their website code. Anyone have
I have the following code that i am trying to change from a regular
I have the following SQL code that runs against a Change Request database. Each
How do I change the following bit of code so that I only have
I have code that references a web service, and I'd like the address of
I have code that looks like the following, which works fine for displaying the
I have code that looks like: //System.Data.IDataRecord dr try { Consolidated = Utility.NullConvert.ToBool(dr[Constants.Data.Columns.cConsolidated], false);

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.