自定义导航栏不起作用

时间:2013-05-28 23:34:50

标签: ios objective-c

所以我有一个Tab ViewController --->导航ViewController -----> abc查看控制器。 现在我想在Abc View Controller Unique上自定义导航栏。

所以我在App Delegate.m中写这个 在 (BOOL)应用程序:(UIApplication *)应用程序didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

UIImage *special = [UIImage imageNamed:@"iphone-heading-select-timezone.png"];

[UINavigationBar appearanceWhenContainedIn:[abcViewController class], nil] setBackgroundImage:special forBarMetrics:UIBarMetricsDefault];

但它现在不工作了。但它在不同的应用程序中工作了6个月。如果我错过了什么或任何建议,请告诉我。 谢谢

1 个答案:

答案 0 :(得分:0)

我认为您不能以这种方式自定义它,因为导航栏包含在UINavigationController中,而不是abcViewController中。尝试将此代码放入-[abcViewController viewWillAppear:]

UIImage *special = [UIImage imageNamed:@"iphone-heading-select-timezone.png"];
[self.navigationController.navigationBar setBackgroundImage:special forBarMetrics:UIBarMetricsDefault];

这是-viewWillDisappear:

[self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
相关问题