自定义UITabBar扩展选择
问题描述:
我想在UITabbar上实现下面的附加图像。自定义UITabBar扩展选择
它是非常简单的,在选择的标签与标签来显示另一个选项卡上的文字和选择拓展,所选择的选项卡会崩溃。
我不知道如何用UItabbar来做到这一点。
如果有人能指出我正确的方向,我将不胜感激。
答
对于自定义选项卡,您在appdelegate类中使用此方法 此方法创建两个选项卡栏项目。 和你设置你的图像..
-(void)SetTabs
{
tabBarController = [[UITabBarController alloc]init];
NSMutableArray *localControllerArray = [[NSMutableArray alloc]initWithCapacity:2];
UIImage *image = [UIImage imageNamed:@"home.png"];
GreetingCardsViewController *GreetingCardsView = [[[GreetingCardsViewController alloc] initWithNibName:@"GreetingCardsViewController" bundle:nil] autorelease];
UITabBarItem *item = [[UITabBarItem alloc]initWithTitle:@"Home" image:image tag:0];
UINavigationController *GreetingCardsViewNavigationController = [[UINavigationController alloc]initWithRootViewController:GreetingCardsView];
GreetingCardsView.tabBarItem = item;
[localControllerArray addObject:GreetingCardsViewNavigationController];
UIImage *image1 = [UIImage imageNamed:@"heart1.png"];
Cards *CardView = [[[Cards alloc] initWithNibName:@"Cards" bundle:nil] autorelease];
UITabBarItem *item1 = [[UITabBarItem alloc]initWithTitle:@"Cards" image:image1 tag:1];
UINavigationController *CardNavigationController = [[UINavigationController alloc]initWithRootViewController:CardView];
CardNavigationController.tabBarItem = item1;
[localControllerArray addObject:CardNavigationController];
[tabBarController setViewControllers:localControllerArray];
[_window addSubview:tabBarController.view];
[localControllerArray release];
}
也许澄清一点基本上图像右侧的选项卡已被选中。而左边的那个没有被选中。在选中该选项卡时,它应该展开并缩小其余选项卡,并显示包含当前选项卡文本的标签,例如“设置” – lancegoh