现在的位置: 首页 > 综合 > 正文

为UINavigationBar添加自定义背景

2013年10月07日 ⁄ 综合 ⁄ 共 548字 ⁄ 字号 评论关闭
@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

抱歉!评论已关闭.