【发布时间】:2014-06-14 22:24:09
【问题描述】:
我正在使用选项卡栏控制器,当我在显示 4 个选项卡之后运行应用程序时,我有 6 个选项卡,并且有更多选项,但在这里我想显示所有不想在 ios 7 中显示“更多”的选项卡。代码是:
UIViewController *viewController1 = [[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];
Calendar *viewController2 = [[Calendar alloc] initWithNibName:@"Calendar" bundle:nil];
nearby *viewController3 = [[nearby alloc] initWithNibName:@"nearby" bundle:nil];
offer *viewController4 = [[offer alloc] initWithNibName:@"offer" bundle:nil];
social *viewController5 = [[social alloc] initWithNibName:@"social" bundle:nil];
contact *viewController6 = [[contact alloc] initWithNibName:@"contact" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController1];
UINavigationController *navController1 = [[UINavigationController alloc] initWithRootViewController:viewController2];
UINavigationController *navController2 = [[UINavigationController alloc] initWithRootViewController:viewController3];
UINavigationController *navController3 = [[UINavigationController alloc] initWithRootViewController:viewController4];
self.tab = [[UITabBarController alloc] init];
self.tab.viewControllers = [NSArray arrayWithObjects:navController, navController1,navController2,navController3,viewController5,viewController6, nil];
[[self.tab tabBar] setBackgroundImage:[UIImage imageNamed:@"tabcrop.png"]];
self.tab.customizableViewControllers = nil;
[[[self.tab moreNavigationController] visibleViewController] setTitle:@""];
[self.tab.tabBar setTranslucent:YES];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont fontWithName:@"AmericanTypewriter" size:10.0f], UITextAttributeFont,
[UIColor yellowColor], UITextAttributeTextColor,
[UIColor redColor], UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0.0f, 1.0f)], UITextAttributeTextShadowOffset,
nil] forState:UIControlStateSelected];
self.window.rootViewController = self.tab;
`
【问题讨论】:
-
为它使用自定义标签栏控制器。在普通标签栏中你不能这样做
-
你不能那样做。你必须使用自定义控件。看到这个github.com/Marxon13/M13InfiniteTabBar
-
@Aakash 非常欢迎你。如果有帮助,请接受我的回答
标签: ios iphone ios7 uitabbarcontroller