通过tintColor属性可以定制UINavigationBar的背景颜色,但如果需要设定渐变色、甚至纹理来说,就需要贴图了。比较“暴力”的一种做法就是通过Category来重新实现- (void) drawRect:(CGRect)rect的实现,“暴力”是因为这种杀伤面很广,所有项目内的UINavigationBar都会因此改变。这点在应用中应该格外小心。
@interface UINavigationBar (ImageBackground)
@end
@implementation UINavigationBar (ImageBackground)
- (void) drawRect:(CGRect)rect {
[[UIImage imageNamed:@"bkimage.png"] drawInRect:rect];
}
@end
iPhone How-to:给导航栏贴图
最新推荐文章于 2015-09-30 10:29:54 发布