将应用程序移植到ipad上,然后在“横向”中,选项卡栏看起来比较稀疏,因此有一个想法,即分离选项卡(其中的6个)并在它们之间插入图像。

我目前使用TabBarKit,它可以完成所有工作,并且UITabbar可以完成更多工作,但这是我的坚持。找不到任何方法来插入空白空间(图像或UIView)(背景已经是图像)吗?

到目前为止,我所做的是以编程方式添加了几个额外的标签栏项,并将图像设置为nil并删除了用户交互。
(我在另一个stackoverflow线程上找到了此解决方案,但这不是一个完美的解决方案)。

我知道UIToolbar具有灵活的空格项目,但是当我尝试将其用作tab bar item时,会引起一些问题。

因此,如果有人对如何在标签栏中插入视图,空白区域等有任何想法,将不胜感激。

更新

开始悬赏,因为我很好奇这是否可以完成。
ipad的横向视图有很大的空间,有人要求我在按钮中间放置一个图像。

如果应用程序被拒绝,那就更愚弄我。任何例子,样品,建议,建议,不胜感激

图片示例:

最佳答案

我同意上面的回答,尽管从技术上讲,这可能不是一个好主意。

自定义标签栏的技巧是隐藏默认标签栏并将您自己的自定义视图放置在该空间中。然后,您可以随心所欲地用按钮,图像填充该视图。这是我的处理方式。

我在AppDelegate中这样设置UITabbarController:

UITabBarController tabBarController = [[UITabBarController alloc] init];
tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1,
                                             viewController2,
                                             viewController3,
                                             nil];
//add the custom tabbarcontroller
CustomTabBar customTabBar = [[CustomTabBar alloc] initWithFrame:CGRectMake(0, self.window.frame.size.height - 60, self.window.frame.size.width, 62)];
    [self.tabBarController.view addSubview:_customTabBar];

tabBarController.tabBar.hidden = YES;
self.window.rootViewController = self.tabBarController;

CustomTabBar是UIView的子类,我在其中放置了自己的自定义按钮。单击此类中的一个按钮时,我将发出如下呼叫:
-(void)firstBtnClicked:(id)sender {
    ((UIButton*)sender).enabled = NO;
    AppDelegate *delegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
    delegate.tabBarController.selectedIndex = 0;
}

07-28 02:36
查看更多