1

我在 UITabbarController 中使用 UISplitViewController。现在的问题是,当我尝试将选项卡栏的半透明属性设置为 NO 时,它会在选项卡栏上方显示一个附加栏,如下图所示。

在此处输入图像描述

您对这个问题的帮助将不胜感激。

谢谢

- (void)setupTabbar {
tabBarController = [[UITabBarController alloc] init];
tabBarController.delegate = self;

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {
    tabBarController.tabBar.barTintColor = UIColorFromRGB(kTabbarTintColor);
    tabBarController.tabBar.tintColor = [UIColor whiteColor];
}

UINavigationController *homeNavController = [[UINavigationController alloc] initWithRootViewController:[root getViewController]];

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {
    homeNavController.navigationBar.barTintColor = UIColorFromRGB(kNavigationTintColor);
    homeNavController.toolbar.barTintColor = UIColorFromRGB(kNavigationTintColor);
}
else {
    homeNavController.navigationBar.tintColor = UIColorFromRGB(kNavigationTintColor);
    homeNavController.toolbar.tintColor = UIColorFromRGB(kNavigationTintColor);
}


if (IS_IPAD_LAYOUT_ENABLED) {
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        _homeSplitViewController = [[UISplitViewController alloc] init];

        category *objCategory = [[category alloc] init];
        objCategory.category_id = kInstructionsCategoryId;

        articleview *instructionsView = (articleview *)[objCategory getViewController];
        UINavigationController *placeHolderNavController = [[UINavigationController alloc] initWithRootViewController:instructionsView];

        _homeSplitViewController.delegate = instructionsView;

        if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {
            placeHolderNavController.navigationBar.barTintColor = UIColorFromRGB(kNavigationTintColor);
            placeHolderNavController.toolbar.barTintColor = UIColorFromRGB(kNavigationTintColor);
        }
        else {
            placeHolderNavController.navigationBar.tintColor = UIColorFromRGB(kNavigationTintColor);
            placeHolderNavController.toolbar.tintColor = UIColorFromRGB(kNavigationTintColor);
        }
        _homeSplitViewController.viewControllers = [NSArray arrayWithObjects:homeNavController, placeHolderNavController, nil];
        _homeSplitViewController.tabBarItem.title = @"Home";
        _homeSplitViewController.tabBarItem.image = [UIImage imageNamed:@"home_ico.png"];
    }
    else {
        homeNavController.tabBarItem.title = @"Home";
        homeNavController.tabBarItem.image = [UIImage imageNamed:@"home_ico.png"];
    }
}
else {
    homeNavController.tabBarItem.title = @"Home";
    homeNavController.tabBarItem.image = [UIImage imageNamed:@"home_ico.png"];
}


settingsviewcontroller *settingsViewController = [[settingsviewcontroller alloc] initWithNibName:@"settingsviewcontroller" bundle:nil];
UINavigationController *settingsNavController = [[UINavigationController alloc] initWithRootViewController:settingsViewController];
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {
    settingsNavController.navigationBar.barTintColor = UIColorFromRGB(kNavigationTintColor);
}
else {
    settingsNavController.navigationBar.tintColor = UIColorFromRGB(kNavigationTintColor);
}

settingsNavController.tabBarItem.title = @"More";
settingsNavController.tabBarItem.image = [UIImage imageNamed:@"more_ico.png"];

SearchViewController *searchViewController = [[SearchViewController alloc] initWithNibName:@"SearchViewController" bundle:nil];
UINavigationController *searchNavController = [[UINavigationController alloc] initWithRootViewController:searchViewController];
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {
    searchNavController.navigationBar.barTintColor = UIColorFromRGB(kNavigationTintColor);
    searchNavController.toolbar.barTintColor = UIColorFromRGB(kNavigationTintColor);
}
else {
    searchNavController.navigationBar.tintColor = UIColorFromRGB(kNavigationTintColor);
    searchNavController.toolbar.tintColor = UIColorFromRGB(kNavigationTintColor);
}
searchNavController.tabBarItem.title = @"Search";
searchNavController.tabBarItem.image = [UIImage imageNamed:@"search_ico.png"];


category *objCategory = [[category alloc] init];
objCategory.category_id = kMenuBar2CatId;
objCategory.screen_type = @"list";
objCategory.short_label = kMenuBar2Title;

UINavigationController *navController2 = [[UINavigationController alloc] initWithRootViewController:[objCategory getViewController]];
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {
    navController2.navigationBar.barTintColor = UIColorFromRGB(kNavigationTintColor);
    navController2.toolbar.barTintColor = UIColorFromRGB(kNavigationTintColor);
}
else {
    navController2.navigationBar.tintColor = UIColorFromRGB(kNavigationTintColor);
    navController2.toolbar.tintColor = UIColorFromRGB(kNavigationTintColor);
}
navController2.tabBarItem.title = kMenuBar2Title;
navController2.tabBarItem.image = [UIImage imageNamed:kMenuBarIcon2];


MyScheduleViewController *placeHolderVC = [[MyScheduleViewController alloc] initWithNibName:@"MyScheduleViewController" bundle:nil];
UINavigationController *navController3 = [[UINavigationController alloc] initWithRootViewController:placeHolderVC];
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {
    navController3.navigationBar.barTintColor = UIColorFromRGB(kNavigationTintColor);
    navController3.toolbar.barTintColor = UIColorFromRGB(kNavigationTintColor);
}
else {
    navController3.navigationBar.tintColor = UIColorFromRGB(kNavigationTintColor);
    navController3.toolbar.tintColor = UIColorFromRGB(kNavigationTintColor);
}
navController3.tabBarItem.title = kMenuBar3Title;
navController3.tabBarItem.image = [UIImage imageNamed:kMenuBarIcon3];

[objCategory release];

if (IS_IPAD_LAYOUT_ENABLED) {
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        tabBarController.viewControllers = [NSArray arrayWithObjects:_homeSplitViewController, searchNavController, navController2, navController3, settingsNavController, nil];
    }
    else {
        tabBarController.viewControllers = [NSArray arrayWithObjects:homeNavController, searchNavController, navController2, navController3, settingsNavController, nil];
    }
}
else {
    tabBarController.viewControllers = [NSArray arrayWithObjects:homeNavController, searchNavController, navController2, navController3, settingsNavController, nil];
}

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {
    self.window.tintColor = [UIColor whiteColor];
}

tabBarController.tabBar.translucent = NO;

self.window.backgroundColor = [UIColor whiteColor];
self.window.rootViewController = tabBarController;

}

4

1 回答 1

2

只需在 master 上添加此代码viewDidLoad

self.splitViewController?.extendedLayoutIncludesOpaqueBars = true
于 2015-07-12T20:38:24.167 回答