简体   繁体   中英

change the color of navigation bar of UINavigationController

I m trying to change the color of navigation bar of UINavigationController by using

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.

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 ?

Nothing, as far as I can tell.

You need to assign self.navigationController to navigationController .

Something like:

self.navigationController = navigationController;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM