【发布时间】:2013-01-02 10:08:37
【问题描述】:
我正在尝试为 iOS 6 实现自定义 UINavigationBar 图像背景,但我没有运气。它所显示的只是 Apple 的普通款(没有后退按钮)。 我在 viewDidLoad 中尝试了以下代码(一次一个):
[[UINavigationBar appearance] setBackgroundImage:myImage forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setBackgroundImage:myImage forBarMetrics:UIBarMetricsDefault];
我通过以下方式呈现所需的视图:
optionViewController *choose= [[optionViewController alloc] initWithNibName:@"optionViewController" bundle:nil];
UINavigationController *aNavController = [[UINavigationController alloc] initWithRootViewController:choose];
[self presentViewController: aNavController animated:YES completion:nil];
任何帮助将不胜感激。谢谢!
【问题讨论】:
-
发生了什么? [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"barImage.png"] forBarMetrics:UIBarStyleDefault];此命令适用于我的代码中的任何地方,适用于 iOS5 和 iOS6。
-
@LêQuýSang 什么都没有发生...它只是显示典型的基本 UINaviationBar 而不是我想要的图像。谢谢
标签: objective-c ios