【发布时间】:2012-07-27 21:40:19
【问题描述】:
目前我们正在使用这段代码在整个应用中自定义 UINavigationBar 背景图像:
@implementation UINavigationBar(MyExtensions)
- (UIImage *)barBackground {
return [UIImage imageNamed:@"GlobalTitleBackground.png"];
}
- (void)didMoveToSuperview {
//iOS5 only
if ([self respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)])
{
[self setBackgroundImage:[self barBackground] forBarMetrics:UIBarMetricsDefault];
}
}
//this doesn't work on iOS5 but is needed for iOS4 and earlier
- (void)drawRect:(CGRect)rect {
//draw image
[[self barBackground] drawInRect:rect];
}
@end
总的来说,这很好用。我遇到的问题是,当我创建一个 MFMailComposeViewController 时,它的背景也会被自定义。
因此,鉴于我现在拥有的代码,是否有可能对所有 UINavigationBars除了由 MFMailComposeViewController 创建的 UINavigationBar 进行自定义?
提前致谢!
【问题讨论】:
标签: objective-c ios cocoa-touch uinavigationbar mfmailcomposeviewcontroller