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 7627417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:27:25+00:00 2026-05-31T05:27:25+00:00

Possible Duplicate: UINavigationBar gradient details I looked around the web but I haven’t found

  • 0

Possible Duplicate:
UINavigationBar gradient details

I looked around the web but I haven’t found a clear example. I have no experience with CGGradient but I need a very simple thing:
I want add a gradient to the NavigationBar of my NavigationController, the gradient should be linear, from top to bottom. I want the start color to be : (88.0, 38.0, 40.0) and the end color (50.0 15.0 16.0). Could you please give me an example of how I could add this gradient to my navigation bar?

Thank you

  • 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-31T05:27:25+00:00Added an answer on May 31, 2026 at 5:27 am

    adjust the color or supply a image if you want

    //                                  #Lighter r,g,b,a                    #Darker r,g,b,a
    #define MAIN_COLOR_COMPONENTS       { 0.153, 0.306, 0.553, 1.0, 0.122, 0.247, 0.482, 1.0 }
    #define LIGHT_COLOR_COMPONENTS      { 0.478, 0.573, 0.725, 1.0, 0.216, 0.357, 0.584, 1.0 }
    
    @implementation UINavigationBar (UINavigationBarCategory)
    
    - (void)drawRect:(CGRect)rect {
        if (imageReady) {
            UIImage *img = [UIImage imageNamed: @"navigation_background.png"];
            [img drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
        } else {
            // Render yourself instead.
            // You will need to adjust the MAIN_COLOR_COMPONENTS and LIGHT_COLOR_COMPONENTS to match your app
    
           // emulate the tint colored bar
           CGContextRef context = UIGraphicsGetCurrentContext();
           CGFloat locations[2] = { 0.0, 1.0 };
           CGColorSpaceRef myColorspace = CGColorSpaceCreateDeviceRGB();
    
           CGFloat topComponents[8] = LIGHT_COLOR_COMPONENTS;
           CGGradientRef topGradient = CGGradientCreateWithColorComponents(myColorspace, topComponents, locations, 2);
           CGContextDrawLinearGradient(context, topGradient, CGPointMake(0, 0), CGPointMake(0,self.frame.size.height/2), 0);
           CGGradientRelease(topGradient);
    
           CGFloat botComponents[8] = MAIN_COLOR_COMPONENTS;
           CGGradientRef botGradient = CGGradientCreateWithColorComponents(myColorspace, botComponents, locations, 2);
           CGContextDrawLinearGradient(context, botGradient,
           CGPointMake(0,self.frame.size.height/2), CGPointMake(0, self.frame.size.height), 0);
           CGGradientRelease(botGradient);
    
           CGColorSpaceRelease(myColorspace);
    
    
           // top Line
           CGContextSetRGBStrokeColor(context, 1, 1, 1, 1.0);
           CGContextMoveToPoint(context, 0, 0);
           CGContextAddLineToPoint(context, self.frame.size.width, 0);
           CGContextStrokePath(context);
    
           // bottom line
           CGContextSetRGBStrokeColor(context, 0, 0, 0, 1.0);
           CGContextMoveToPoint(context, 0, self.frame.size.height);
           CGContextAddLineToPoint(context, self.frame.size.width, self.frame.size.height);
           CGContextStrokePath(context);
        }
    }
    

    source

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: regex for URL including query string I have a text or message.
Possible Duplicate: How to call a JavaScript function from PHP? I have a php
Possible Duplicate: Extracting dollar amounts from existing sql data? I have a column in
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have
Possible Duplicate: git - removing a file from source control (but not from the
Possible Duplicate: Why do I get a null pointer exception from TabWidget? I have
Possible Duplicate: Python urllib2 Progress Hook I have a script which uploads a file
Possible Duplicate: Split A4 PDF page into two A5 and back again I have
Possible Duplicate: Creating a left-arrow button (like UINavigationBar's “back” style) on a UIToolbar I
Possible Duplicate: Custom UINavigationBar Background I am creating my uinavigation controller programatically in the

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.