Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove Gradient on UINavigationBar

How can I remove the default gradient on a UINavigationBar? What property do I set to do this?

like image 846
CodeGuy Avatar asked Feb 05 '11 03:02

CodeGuy


1 Answers

You can remove the gradient and set your own solid color by popping this code into the class that has the navigation bar. You can change the UIColor to whatever color you need. Note that this code needs to be outside of another implementation, so whatever .m file you put it in put it before the @implmentation of the class already implemented in that file.

@implementation UINavigationBar (UINavigationBarCategory)   
- (void)drawRect:(CGRect)rect {
UIColor *color = [UIColor blueColor];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColor(context, CGColorGetComponents( [color CGColor]));
CGContextFillRect(context, rect);
}   
@end
like image 197
Nitrex88 Avatar answered Sep 21 '22 22:09

Nitrex88