在uitabbar中切换视图后,UINavigationBar变为透明

时间:2013-09-07 18:14:49

标签: ios objective-c uinavigationcontroller uitabbarcontroller uinavigationbar

(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions方法中,我使用GeneralOptionsTableViewControllerGeneralOptionsMapViewController的实例初始化了一个UINavigationController实例。 navigationBar颜色设置为绿色。但是,当我在UINavigationController与GeneralOptionsTableViewControllerGeneralOptionsMapViewController之间切换时,navigationBar变得透明。我尝试在viewWillAppear方法中重置导航栏颜色,但似乎无效。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{    
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    GeneralObjectTableViewController *generalObjectTableViewController = [[GeneralObjectTableViewController alloc] init];
    GeneralObjectMapViewController *generalObjectMapViewController = [[GeneralObjectMapViewController alloc]init];
    UINavigationController *navigationController = [[UINavigationController alloc]initWithRootViewController:generalObjectTableViewController];
    navigationController.navigationBar.barTintColor = [UIColor greenColor];


    UITabBarController *tabBarController = [[UITabBarController alloc]init];
    [tabBarController setViewControllers:[NSArray arrayWithObjects:navigationController, generalObjectMapViewController, nil]];

    [self.window setRootViewController:tabBarController];

    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
}

0 个答案:

没有答案