Reputation: 34735
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.
How do I remove this?
Upvotes: 1
Views: 4670
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
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
Reputation: 16664
It's not possible. However you can use custom background images. Check UIAppearance
documentation
Upvotes: 2