为UINavigationBar添加自定义背景

简介: @implementation UINavigationBar (UINavigationBarCategory) - (void)drawRect:(CGRect)rect { //颜色填充 // UIColor *color = [UIColor redColor]; // ...

@implementation UINavigationBar (UINavigationBarCategory)
- (void)drawRect:(CGRect)rect {
	//颜色填充
//	UIColor *color = [UIColor redColor];
//	CGContextRef context = UIGraphicsGetCurrentContext();
//	CGContextSetFillColor(context, CGColorGetComponents( [color CGColor]));
//	CGContextFillRect(context, rect);
//	self.tintColor = color;
	//图片填充
	UIColor *color = [UIColor colorWithRed:46.0f/255.0f green:87.0f/255.0f blue:29.0f/255.0f alpha:1.0f];
	UIImage *img	= [UIImage imageNamed: @"bg.png"];
	[img drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
	self.tintColor = color;
}
@end

图示:

相关文章
|
iOS开发 缓存 API
定制UINavigationBar
在开发中经常需要定制某些界面,navigationController的navigationBar就是一个很典型的例子,比如要修改背景图、后退按钮等等。
986 0
UINavigationBar-使用总结
UINavigationBar-使用总结
131 0
|
容器
悬浮指示器布局-自定义控件
这是一个悬浮 【指示器 - 菜单】的控件容器,支持 上滑|下滑 的百分比进度跟踪,去掉了对 layout布局文件的依赖,去掉了对values 属性文件的依赖,由于这是第二次维护这个小demo了,以后会的多了,在改进。
763 0
一个自定义的指南针样式的控件
代码:/Files/cappuccino/Compass.rar
744 0
|
存储 JSON 前端开发
【红隼书签】自定义光影、自定义背景、亮度和主题功能
【红隼书签】是一款简洁的在线书签导航网站。
122 1
html+css实战84-显示模式-层叠性
html+css实战84-显示模式-层叠性
99 0
html+css实战84-显示模式-层叠性
|
JavaScript 前端开发
按钮实现鼠标悬停背景色渐变的动画特效
Title input { position: absolute; top: 50%; ...
1320 0

热门文章

最新文章