设置标签栏
private func creatNavigationController(dict: [String: AnyObject]) -> DTNavigationController{
guard let className = dict["className"] as? String,
let title = dict["title"] as? String,
let imageName = dict["imageName"] as? String,
let selectImageName = dict["selectImageName"] as? String,
let cls = NSClassFromString(Bundle.main.namespace + "." + className) as? DTViewController.Type
else {
return DTNavigationController()
}
let vc = cls.init()
vc.title = title
vc.tabBarItem.image = UIImage(named: imageName)
vc.tabBarItem.selectedImage = UIImage(named: selectImageName)?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)//使用图片原来颜色
let attributes = [NSForegroundColorAttributeName :UIColor.black,
NSFontAttributeName: UIFont(name: "Heiti SC", size: 12)!]
let selattributes = [NSForegroundColorAttributeName :UIColor(red: 251.0/255.0, green: 0, blue: 77.0/255.0, alpha: 1),
NSFontAttributeName: UIFont(name: "Heiti SC", size: 12)!]
vc.tabBarItem.setTitleTextAttributes(attributes , for: UIControlState.normal)
vc.tabBarItem.setTitleTextAttributes(selattributes , for: UIControlState.selected)
let uNC = DTNavigationController(rootViewController: vc)
return uNC
}