我为iOS 7项目中的导航栏设置了2个不同的背景图像,具体取决于设备的方向。该代码是基于苹果下面的例子...当UIBarMetricsLandscapePhone被弃用时设置导航栏背景图像iOS 8
https://developer.apple.com/library/ios/samplecode/NavBar/Introduction/Intro.html
现在我的景观形象不再装载更新到iOS 8。下面的苹果页告诉我UIBarMetricsLandscapePhone已经过时......
有谁知道iOS 8的方式做到这一点?一些正常的developer.apple.com网页似乎在一天中的大部分时间都停止运行。看到我的代码的要点如下。
@interface cQPMNavigationViewController : UINavigationController
@end
@implementation cQPMNavigationViewController
- (void)applyImageBackgroundToTheNavigationBar
{
UIImage *bgImagePortrait = [UIImage imageNamed:@"portrait_bg.png"];
UIImage *bgImageLandscape = [UIImage imageNamed:@"landscape_bg.png"];
bgImagePortrait = [bgImagePortrait resizableImageWithCapInsets:UIEdgeInsetsMake(0,0,bgImagePortrait.size.height - 1,bgImagePortrait.size.width - 1)];
bgImageLandscape = [bgImageLandscape resizableImageWithCapInsets:UIEdgeInsetsMake(0,0,bgImageLandscape.size.height - 1,bgImageLandscape.size.width - 1)];
[[UINavigationBar appearance] setBackgroundImage:bgImagePortrait
forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundImage:bgImageLandscape
forBarMetrics:UIBarMetricsLandscapePhone];
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self applyImageBackgroundToTheNavigationBar];
}
@end
感谢
感谢您指点我正确的方向,我会张贴我的解决方案根据您的帮助莫。 – Niall 2014-09-29 12:40:38