iOS:UIView上方的TabBar控制器

时间:2015-06-22 09:29:47

标签: ios xcode autolayout uitabbarcontroller

我的标签栏位于我的视图上方时出现问题 我正在使用iOS 8和Autolayout

我的主视图有一个按钮,可以打开另一个带有标签栏的视图:

-(IBAction)btnOpen:(id)sender
{

            Home* homevc = [[Home alloc] initWithNibName:@"Home_iPhone" bundle:nil];

            UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:homevc];
            [nc.tabBarItem setTitle:@"Home"];
            [nc.tabBarItem setImage:[UIImage imageNamed:@"home_icon.png"]];


            Search *searchvc = [[Search alloc] initWithNibName:@"Search_iPhone" bundle:nil];
            [searchvc.tabBarItem setTitle:@"Search"];
            [searchvc.tabBarItem setImage:[UIImage imageNamed:@"search_icon.png"]];

            UITabBarController *tabController = [[UITabBarController alloc] init];
            [tabController setViewControllers:[NSArray arrayWithObjects:nc,searchvc, nil]];

            UIColor * color = [UIColor colorWithRed:191/255.0f green:50/255.0f blue:46/255.0f alpha:1.0f];

            [[UITabBar appearance] setTintColor:color];
            [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:color, NSForegroundColorAttributeName, nil]
                                                     forState:UIControlStateSelected];
            [self presentViewController:tabController animated:YES completion:nil];

}

如何将主页视图放在标签栏上方?

0 个答案:

没有答案