Remove gradient on UINavigationBar

How to remove default gradient on UINavigationBar? What property can I do for this?

+5
source share
1 answer

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

@implementation UINavigationBar (UINavigationBarCategory)   
- (void)drawRect:(CGRect)rect {
UIColor *color = [UIColor blueColor];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColor(context, CGColorGetComponents( [color CGColor]));
CGContextFillRect(context, rect);
}   
@end
+23
source

All Articles