设置导航栏的背景图像有时会显示不正确

时间:2012-07-23 05:53:38

标签: objective-c cocoa-touch uinavigationbar

enter image description here

如果我正在设置导航栏背景图像,它在应用程序中工作正常,但如果我从我的邮件编辑器打开此屏幕,它将会中断。谁能告诉我这段代码有什么问题?

UIImage *gradientImage44 = [[UIImage imageNamed:@"image.png"]
                                    resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
[[UINavigationBar appearance] setBackgroundImage:gradientImage44 
                                           forBarMetrics:UIBarMetricsDefault];

@implementation UINavigationBar (CustomBackground)

- (void)drawRect:(CGRect)rect
{
    UIImage *navBackgroundImage = [[UIImage imageNamed:@"image.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:0.0];
    [navBackgroundImage drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}

@end

0 个答案:

没有答案