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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:18:54+00:00 2026-06-03T00:18:54+00:00

UITabBar by default draws a subtle gradient: I would like to replicate this look

  • 0

UITabBar by default draws a subtle gradient:

UITabBar Gradient Black

I would like to replicate this look and feel in my code with any given tintColor. Just to make it clear: I do not want to set a tintColor on UITabBar (which is possible since iOS 5), I would like to draw the gradient in my own UIView.

I know how to draw the gradient, my problem is how to derive the colors for the gradient from the tintColor. I was thinking about getting the brightness of the color and generating the other colors with different brightness-settings, but that doesn’t seem to work that well and looks not as good as I would like it to look.

Custom Drawn Gradient

I need the code for my open source TabBarController: https://github.com/NOUSguide/NGTabBarController

Here’s my current code for creating the gradient:

UIColor *baseColor = self.tintColor;
CGFloat hue, saturation, brightness, alpha;

// TODO: Only works on iOS 5
[baseColor getHue:&hue saturation:&saturation brightness:&brightness alpha:&alpha];

// That's the question, how to compute the colors ...
NSArray *colors = [NSArray arrayWithObjects:
                   [UIColor colorWithHue:hue saturation:saturation brightness:brightness+0.2 alpha:alpha],
                   [UIColor colorWithHue:hue saturation:saturation brightness:brightness+0.15 alpha:alpha],
                   [UIColor colorWithHue:hue saturation:saturation brightness:brightness+0.1 alpha:alpha],
                   baseColor, nil];
NSUInteger colorsCount = colors.count;
CGColorSpaceRef colorSpace = CGColorGetColorSpace([[colors objectAtIndex:0] CGColor]);

NSArray *locations = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0], 
                      [NSNumber numberWithFloat:0.25], 
                      [NSNumber numberWithFloat:0.49], 
                      [NSNumber numberWithFloat:0.5], nil];
CGFloat *gradientLocations = NULL;
NSUInteger locationsCount = locations.count;

gradientLocations = (CGFloat *)malloc(sizeof(CGFloat) * locationsCount);

for (NSUInteger i = 0; i < locationsCount; i++) {
    gradientLocations[i] = [[locations objectAtIndex:i] floatValue];
}

NSMutableArray *gradientColors = [[NSMutableArray alloc] initWithCapacity:colorsCount];
[colors enumerateObjectsUsingBlock:^(id object, NSUInteger index, BOOL *stop) {
    [gradientColors addObject:(id)[(UIColor *)object CGColor]];
}];

_gradientRef = CGGradientCreateWithColors(colorSpace, (__bridge CFArrayRef)gradientColors, gradientLocations);

if (gradientLocations) {
    free(gradientLocations);
}
  • 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-06-03T00:18:56+00:00Added an answer on June 3, 2026 at 12:18 am

    Here is an excellent tutorial: http://www.raywenderlich.com/2079/core-graphics-101-shadows-and-gloss
    look at the part with the gloss effect.

    Also here: http://cocoawithlove.com/2008/09/drawing-gloss-gradients-in-coregraphics.html

    And a complete code sample here: http://www.mlsite.net/blog/?page_id=372

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

Sidebar

Related Questions

Is it possible to make a UITabBar look like a UIToolBar, while maintaining its
I have this code - (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item What I am looking for
I have a UITabBar which controls multiple Views and I would like to hide
I have this case where I am using a custom UITabBar in my application.
I have a UITabBar with 5 view controllers in it. When any of the
I am loading a UITabBarController inside a UINavigationController . By default the UITabBar for
Our designers want to change the color of the default UITabBar. Of course they
In UITabBar it is possible to add a standard button by clicking on the
I have a UITabBar + UINavigationController application which often needs data from the internet.
I have a UITabBar in the detail view of my navigation based application. 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.