我试图使用
更改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控制器导航栏的颜色。
提前致谢。
答案 0 :(得分:4)
看看这两行:
UINavigationController *navigationController=[[UINavigationController alloc] init];
self.navigationController.navigationBar.tintColor = [UIColor brownColor];
第一个navigationController
与self.navigationController
之间的连接是什么?
据我所知,没什么。
您需要将self.navigationController
分配给navigationController
。
类似的东西:
self.navigationController = navigationController;