簡體   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