故事板中标签栏的菜单

Has*_*ood 15 iphone xcode uitabbar ios

目前我有一个标准的标签栏,当点击进入相应的viewController时.但是当我选择更多标签时,我想从标签栏中弹出一个菜单,如下图所示.

在此输入图像描述

有任何建议实施吗?提前致谢.

May*_*nna 0

它的用户界面不是很好,但如果你愿意的话。

首先你必须实现 UITabbarControllerDelegate 的委托方法,如下所示

func tabBarController(_ tabBarController: UITabBarController, shouldSelect 
 viewController: UIViewController) -> Bool {

    if viewController.classForCoder == moreViewController.self
    {   
        let popvc = MoreSubMenuViews(nibName: "MoreSubMenuViews", bundle: Bundle.main)
        self.addChildViewController(popvc)

        let tabbarHeight = tabBar.frame.height
        let estimatedWidth:CGFloat = 200.0
        let estimatedHeight:CGFloat = 300.0
        popvc.view.frame = CGRect(x:self.view.frame.width - estimatedWidth, y: self.view.frame.height - estimatedHeight - tabbarHeight, width: estimatedWidth, height: estimatedHeight)

        self.view.addSubview(popvc.view)

        popvc.didMove(toParentViewController: self)

        print("sorry stop here")
        return true // if you want not to select return false here

    }else{

        //remove popup logic here if opened
        return true
    }
} 
Run Code Online (Sandbox Code Playgroud)

这里moreViewController是最后一个选项卡控制器,MoreSubMenuViews是 nib/xib 文件,其中包含图像中显示的按钮。