github地址:https://github.com/DreamingLuo/LGTabbar
封装了两个方法
private func addChildViewControllers() {
addChildViewController(FirstViewController(), title: "首页", imageName: "shouye.png", selectedImageName: "shouye1.png")
addChildViewController(SecondViewController(), title: "部门", imageName: "luru.png", selectedImageName: "luru1.png")
addChildViewController(ThirdViewController(), title: "图表", imageName: "tubiao.png", selectedImageName: "tubiao1.png")
addChildViewController(FourthViewController(), title: "我的", imageName: "wode.png", selectedImageName: "wode.png")
}
func addChildViewController(childController: UIViewController, title: String, imageName: String, selectedImageName: String) {
childController.tabBarItem.image = UIImage(named: imageName)
childController.tabBarItem.selectedImage = UIImage(named: selectedImageName)
childController.title = title
let nav = UINavigationController(rootViewController: childController)
addChildViewController(nav)
}
实现点击每个item切换页面并改变item颜色
网友评论