Tig*_*ing 2 iphone uiimage ios uiappearance
我正在尝试使用iOS 5中的外观方法使用背景图像.我正在使用以下语句设置背景图像:
UIImage *portraitImage = [UIImage imageNamed:@"test_bar_portrait.png"];
UIImage *landscapeImage = [UIImage imageNamed:@"test_bar_landscape.png"];
[[UINavigationBar appearance] setBackgroundImage:portraitImage forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundImage:landscapeImage forBarMetrics:UIBarMetricsLandscapePhone];
Run Code Online (Sandbox Code Playgroud)
当我运行应用程序时,正确的图像以纵向和横向显示,但当我旋转回肖像时,它仍然显示了横向图像.
我在这里创建了一个示例测试应用程序:http: //dl.dropbox.com/u/7834263/Appearance%20Test.zip
以及正在发生的事情的屏幕截图:



我尝试将您的代码更改为以下内容,它对我来说效果很好.
UIImage *portraitImage = [UIImage imageNamed:@"test_bar_portrait.png"];
UIImage *landscapeImage = [UIImage imageNamed:@"test_bar_landscape.png"];
[[UINavigationBar appearance] setBackgroundImage:portraitImage forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundImage:landscapeImage forBarMetrics:UIBarMetricsLandscapePhone];
self.navigationController.navigationBar.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
Run Code Online (Sandbox Code Playgroud)
请检查一下.
| 归档时间: |
|
| 查看次数: |
1748 次 |
| 最近记录: |