繁体   English   中英

更改UINavigationController导航栏的颜色

[英]change the color of navigation bar of UINavigationController

我正在尝试通过使用更改UINavigationController导航栏的颜色

self.navigationController.navigationBar.tintColor = [UIColor brownColor];   

在下面给定的代码,但不能正常工作。

 #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;
}

谁能说出为什么它没有改变UINavigation Controller导航栏的颜色。

提前致谢。

看这两行:

UINavigationController *navigationController=[[UINavigationController alloc] init];

self.navigationController.navigationBar.tintColor = [UIColor brownColor];  

什么将第一个navigationControllerself.navigationController连接起来?

据我所知,没有。

您需要将self.navigationController分配给navigationController

就像是:

self.navigationController = navigationController;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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