swift tabbar框架

2016-11-21  本文已影响0人  func_老衲姓罗

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颜色

上一篇下一篇

猜你喜欢

热点阅读