它的用户界面不是很好,但如果你愿意的话。
首先你必须实现 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 文件,其中包含图像中显示的按钮。
| 归档时间: |
|
| 查看次数: |
481 次 |
| 最近记录: |