Federer
Federer

Reputation: 34735

Remove gloss/gradient effect from Navigation/Tab bars

I would like to remove the gradient effect that occurs in the UINavigationBar and UITabBar. The following picture shows an example tab bar using the custom UIColor of 7/29/88 (RGB), set using setTintColor:color and as you can see, the tab bar has a gloss in the top half of the bar.

enter image description here

How do I remove this?

Upvotes: 1

Views: 4670

Answers (3)

XJones
XJones

Reputation: 21967

Depends on your definition of "remove". In iOS 6.x (didn't test iOS 4/5) the following works.

// this will show a tab bar with a solid background color
tabBar.backgroundImage = [UIImage new];
tabBar.backroundColor = [UIColor blueColor];

// this will show a navigation bar with a solid background color
[navBar setBakgroundImage:[UIImage new]
            forBarMetrics:UIBarMetricsDefault]];
navBar.shadowImage = [UIImage new];
navBar.backgroundColor = [UIColor blueColor];
navBar.tintColor = [UIColor blueColor];

Upvotes: 6

Pach
Pach

Reputation: 861

I remove the gradient effect from my Navigation Bar, you can try this code and see if its works for you too.

//First, create your own Navigation Bar Class, and add this to your init method.

self.tintColor = [UIColor clearColor];
self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"yourImage"]];

//Add this to your DrawRect method
- (void)drawRect:(CGRect)rect {
    UIColor *color = [UIColor colorWithPatternImage:[UIImage imageNamed:@"yourImage"]]; 
   //If you want a plain color change this

    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColor(context, CGColorGetComponents([color CGColor]));
    CGContextFillRect(context, rect);
}

Upvotes: 2

Shmidt
Shmidt

Reputation: 16664

It's not possible. However you can use custom background images. Check UIAppearance documentation

Upvotes: 2

Related Questions