[英]change the color of navigation bar of UINavigationController
I m trying to change the color of navigation bar of UINavigationController by using 我正在尝试通过使用更改UINavigationController导航栏的颜色
self.navigationController.navigationBar.tintColor = [UIColor brownColor];
in the below given code but its not working. 在下面给定的代码,但不能正常工作。
#import "uitextviewAppDelegate.h"
#import "uitextviewViewController.h"
@implementation uitextviewAppDelegate
@synthesize window = _window;
@synthesize viewController = _viewController;
@synthesize navigationController = _navigationController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[uitextviewViewController alloc] init];
UINavigationController *navigationController=[[UINavigationController alloc] init];
self.navigationController.navigationBar.tintColor = [UIColor brownColor];
[navigationController pushViewController:_viewController animated:YES];
[_window addSubview:navigationController.view];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
Can anyone tell why it is not changing the color of the navigation bar of the UINavigation Controller. 谁能说出为什么它没有改变UINavigation Controller导航栏的颜色。
Thanks in advance. 提前致谢。
Looking at these two lines: 看这两行:
UINavigationController *navigationController=[[UINavigationController alloc] init];
self.navigationController.navigationBar.tintColor = [UIColor brownColor];
What connects the first navigationController
with self.navigationController
? 什么将第一个
navigationController
与self.navigationController
连接起来?
Nothing, as far as I can tell. 据我所知,没有。
You need to assign self.navigationController
to navigationController
. 您需要将
self.navigationController
分配给navigationController
。
Something like: 就像是:
self.navigationController = navigationController;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.