【发布时间】:2010-05-21 06:11:50
【问题描述】:
我需要在导航栏上绘制背景图像或设置色调,但我还需要让导航栏正常显示的选项。我目前正在使用一个类别来支持如果我的应用没有指定背景图片,我可以做些什么来确保 drawRect 方法正常工作?
I.E. -
@implementation UINavigationBar (UINavigationBarCategory)
- (void)drawRect:(CGRect)rect {
if(hasImage){
UIImage *img = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://myimageurl.com/img.jpg"]]];
[img drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}else{
??????
}
}
@end
【问题讨论】:
标签: objective-c iphone cocoa-touch