一般以软件中会有导航条,系统会默认提供几种颜色,但仍然可以选择的比较少,可以通过自定义颜色来设置导航条的颜色,具体方法只要一句话就可以了:
navigationController.navigationBar.tintColor = [UIColor colorWithRed:(21.0/255.0) green:(153.0 / 255.0) blue:(224.0 / 255.0) alpha:1];
导航条的颜色也就变成了你设置的颜色,这个软件所有的导航条都变成设置后的颜色。如果想要改回来,再重新设置。
navigationController.navigationBar.tintColor = [UIColor colorWithRed:(21.0/255.0) green:(153.0 / 255.0) blue:(224.0 / 255.0) alpha:1];
导航条的颜色也就变成了你设置的颜色,这个软件所有的导航条都变成设置后的颜色。如果想要改回来,再重新设置。
@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect
{
UIImage *p_w_picpath = [UIImage p_w_picpathNamed: @"xxxx.x"];
[p_w_picpath drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end
这个还可以换图片背景喔
- (void)drawRect:(CGRect)rect
{
UIImage *p_w_picpath = [UIImage p_w_picpathNamed: @"xxxx.x"];
[p_w_picpath drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end
这个还可以换图片背景喔
@implementation UINavigationBar (CustomImage) - (void)drawRect:(CGRect)rect { UIImage *p_w_picpath = [UIImage p_w_picpathNamed: @"xxxx.x"]; [p_w_picpath drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; [p_w_picpath set]; } @end |
转载于:https://blog.51cto.com/zhaohaiyang/756388