美文网首页
UITabBarController

UITabBarController

作者: 大鹏你我他 | 来源:发表于2020-08-31 15:41 被阅读0次

        override func viewDidLoad() {

            super.viewDidLoad()

            view.backgroundColor = UIColor.white

            lethomeVC =FHomeVC()

            letfindVC =FFindVC()

            letmyVC =FMyVC()

            addChildVC(vc: homeVC, title:"首页",normalImage:"tabbar_home",selectImage:"tabbar_home_sel")

            addChildVC(vc: findVC,title:"聊天",normalImage:"tabbar_social",selectImage:"tabbar_social_sel")

            addChildVC(vc: myVC,title:"我的",normalImage:"tabbar_mine",selectImage:"tabbar_mine_sel")

            // Do any additional setup after loading the view.

        }

        funcaddChildVC(vc:UIViewController,title:NSString,normalImage:NSString,selectImage:NSString) {

            letnavVC =UINavigationController(rootViewController: vc)

            navVC.tabBarItem.title= titleasString

            navVC.tabBarItem.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.black], for: .selected)

            navVC.tabBarItem.image = UIImage(named: normalImage as String)?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal)

            navVC.tabBarItem.selectedImage = UIImage(named: selectImage as String)?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal)

            self.tabBar.unselectedItemTintColor = UIColor.black

            self.addChild(navVC)

        }

    相关文章

      网友评论

          本文标题:UITabBarController

          本文链接:https://www.haomeiwen.com/subject/dhousktx.html