I have a UINavigationController that I instantiated programatically. Is there a way to set the background 开发者_运维技巧to an image (how its done on many sites) instead of standard text.
I have found some code by overriding GRect but it ever gets called
-(void)drawRect:(CGRect)rect {
CGRect currentRect = CGRectMake(0,15,200,25);
UIImage *image = [UIImage imageNamed:@"topHeader.png"]; [image
drawInRect:currentRect]; }
Define your -drawRect: definition like this in your root view controller's .m file:
@implementation UINavigationBar (CustomImage)
-(void)drawRect:(CGRect)rect {
CGRect currentRect = CGRectMake(0,15,200,25);
UIImage *image = [UIImage imageNamed:@"topHeader.png"]; [image
drawInRect:currentRect]; }
@end
精彩评论