0
如何將TABBAR控件放置在視圖頂部control.by默認情況下它位於底部如何放置..?將Tabbar控制器放在視圖控制器的頂部
使用下面的代碼來執行:
UIImage* tabBarBackground = [UIImage imageNamed:@"footer-bg.png"];
[[UITabBar appearance] setBackgroundImage:tabBarBackground];
[[UITabBar appearance]setSelectionIndicatorImage:[UIImage imageNamed:@"footer-hover-bg.png"]];
if(IS_IOS_7)
{
[[appDelegate.tabBarController tabBar] setSelectionIndicatorImage:[UIImage imageNamed:@"footer-hover-bg.png"]];
[[UITabBar appearance] setTintColor:[UIColor blackColor]];
}
appDelegate.tabBarController.tabBar.frame = CGRectMake(0, 20, 320, 50);
appDelegate.tabBarController.delegate=self;
UIView *view=[[UIView alloc]initWithFrame:CGRectMake(0, -20, 320, 600)];
viewControllers = [[NSMutableArray alloc] init];
MainViewController *view1 = [[MainViewController alloc] init];
UINavigationController *nav1=[[UINavigationController alloc]initWithRootViewController:view1];
[viewControllers addObject:nav1];
ViewController1 *view2 = [[ViewController1 alloc] init];
UINavigationController *nav2=[[UINavigationController alloc]initWithRootViewController:view2];
[viewControllers addObject:nav2];
[appDelegate.tabBarController setViewControllers:viewControllers];
appDelegate.tabBarController.tabBarController.view.frame=CGRectMake(0, 0, 320, 480);
[view addSubview:appDelegate.tabBarController.view];
[self.view addSubview:view];
UITabBarItem *tabBarItem1 = [appDelegate.tabBarController.tabBar.items objectAtIndex:0];
UITabBarItem *tabBarItem2 = [appDelegate.tabBarController.tabBar.items objectAtIndex:1];
[tabBarItem1 setFinishedSelectedImage:[UIImage imageNamed:[arraySelectedImages objectAtIndex:0]] withFinishedUnselectedImage:[UIImage imageNamed:[arrayUnselectedImages objectAtIndex:0]]];
[tabBarItem2 setFinishedSelectedImage:[UIImage imageNamed:[arraySelectedImages objectAtIndex:1]] withFinishedUnselectedImage:[UIImage imageNamed:[arrayUnselectedImages objectAtIndex:1]]];
我如何做同樣的使用故事板?
我已經使用UITabBarController並添加了它的視圖。我可以改變它的框架,以便我可以將它添加到上面。 – user2798258
編號如果你使用UITabBarController,你將無法改變位置 –
可以請你給我示例鏈接Tabbar使用故事板。我找不到:( – user2798258