我有一个要求,我需要从左下角创建一个侧边栏/导航抽屉(在所有屏幕中都是固定的侧边栏),并且底部有一个标签栏,用于显示基于数组的数据。我能够以编程方式创建选项卡栏,但是找不到从左下角创建导航抽屉以与选项卡栏一起显示的方法(汉堡图标从左下角打开导航抽屉)
此外,我需要随机更新选项卡栏项目,没有固定的项目列表。因为项目取决于导航项目(实际上,导航菜单项目和选项卡栏项目都是相同的),并且会随机变化。如何以编程方式实现这一目标?标签栏项目限制为4。 谢谢你的帮助。请参阅下面的链接以获取示例应用的屏幕截图
Tab bar along with nav drawer item
标签栏的当前代码:
import UIKit
class MainTabBar: UITabBarController {
private let HomeVc = HomeVC()
private let TESt1Vc = TESt1VC()
private let TEst2Vc = TEst2VC()
private let Test3Vc = Test3VC()
override func viewDidLoad() {
super.viewDidLoad()
viewControllers = [createController(title: "Home", imageName: "Menu", vc: HomeVC), createController(title: "TESt1", imageName: "Menu", vc: TESt1Vc), createController(title: "TEst2", imageName: "Menu", vc: TEst2Vc), createController(title: "Test3", imageName: "Menu", vc: Test3Vc)]
}
private func createController(title: String, imageName: String, vc: UIViewController) -> UINavigationController {
let recentVC = UINavigationController(rootViewController: vc)
recentVC.tabBarItem.title = title
recentVC.tabBarItem.image = UIImage(named: imageName)
return recentVC
}
}