欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

swift UITabBarController 嵌套 UINavigationController

程序员文章站 2022-04-01 12:42:28
...
		//大致相当于 tabar管理3个navigation.
 		tabBarCtrl = UITabBarController()
        let viewHome = ViewHome()
        viewHome.tabBarItem.image = UIImage(systemName: "house")
        viewHome.tabBarItem.title = "组件"
        let viewIcon = ViewIcon()
        viewIcon.tabBarItem.image = UIImage(systemName: "photo.on.rectangle")
        viewIcon.tabBarItem.title = "图标"
        let viewSetting = ViewSetting()
        viewSetting.tabBarItem.image = UIImage(systemName: "gearshape")
        viewSetting.tabBarItem.title = "设置"
        let view1 = UINavigationController.init(rootViewController: viewHome)
        let view2 = UINavigationController.init(rootViewController: viewIcon)
        let view3 = UINavigationController.init(rootViewController: viewSetting)
        
        tabBarCtrl.addChild(view1)
        tabBarCtrl.addChild(view2)
        tabBarCtrl.addChild(view3)
        tabBarCtrl.selectedIndex = 0
        self.window?.rootViewController = tabBarCtrl
        window?.makeKeyAndVisible()
相关标签: iOS swift