UITabBarController

    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)