删除UINavigationBar上的渐变 [英] Remove Gradient on UINavigationBar

查看:125
本文介绍了删除UINavigationBar上的渐变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何删除UINavigationBar上的默认渐变?我设置了什么属性来执行此操作?

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

推荐答案

您可以通过将此代码弹出来删除渐变并设置自己的纯色具有导航栏的类。您可以将UIColor更改为您需要的任何颜色。请注意,此代码需要在另一个实现之外,因此无论您使用什么.m文件,都要将它放在已在该文件中实现的类的@implmentation之前。

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

这篇关于删除UINavigationBar上的渐变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆