我正在尝试实现标签栏菜单。最初,对于iphone7或iphone 11 pro max,它应该显示2个菜单项。如果应用运行的是ipad,则它应在标签栏控制器中显示4个菜单项。
是否有可能实现这一目标?如果是的话,您可以建议我提供样品。
例如,iphone7或iphone 11 pro max:
标签栏项目类似于tab1和tab2
对于ipad标签栏项目,例如tab1,tab2,tab3和tab4。
任何帮助,不胜感激...
let firstVC = FirstViewController()
firstVC.tabBarItem = UITabBarItem(tabBarSystemItem: .one, tag: 0)
let secondVC = SecondViewController()
secondVC.tabBarItem = UITabBarItem(tabBarSystemItem: .two, tag: 1)
let thirdVC = ThirdViewController()
thirdVC.tabBarItem = UITabBarItem(tabBarSystemItem: .three, tag: 2)
let fourthVC = FourthViewController()
fourthVC.tabBarItem = UITabBarItem(tabBarSystemItem: .four, tag: 3)
if UIDevice.current.userInterfaceIdiom == .pad {
let tabBarList = [firstVC, secondVC, thirdVC, fourthVC]
viewControllers = tabBarList
} else {
let tabBarList = [firstVC, secondVC]
viewControllers = tabBarList
}
yourTabBarController.viewControllers = viewControllers
[在iPhone,iPhone pro或iPad上最多为5。当您添加第六个时,您将得到前四个,再加上一个“其他”选项卡。使用标准的UITabBarController不能更改此设置。点击更多标签时,您可以以网格形式显示多个标签。
搜索github或其他资源,例如pods。