UITabBarViewController.swift
import UIKit
class UITabBarViewController: UITabBarController {
class func UITabBarViewController() ->UITabBarController{
let vc1 = FirstViewController()
let vc2 = SecondViewController()
let vc3 = ThirdViewController()
let vc4 = FourthController()
let nvc1:UINavigationController = nav(rootViewController: vc1)
let nvc2:UINavigationController = nav(rootViewController: vc2)
let nvc3:UINavigationController = nav(rootViewController: vc3)
let nvc4:UINavigationController = nav(rootViewController: vc4)
let tabbar1 = UITabBarItem(title: "标题0", image: (Public .getImgView("nenu_first_off")) , selectedImage: (Public .getImgView("nenu_first_on")))
let tabbar2 = UITabBarItem(title: "标题1", image: (Public .getImgView("nenu_second_off")), selectedImage: (Public .getImgView("nenu_second_on")))
let tabbar3 = UITabBarItem(title: "标题2", image: (Public .getImgView("nenu_third_off")), selectedImage: (Public .getImgView("nenu_third_on")))
let tabbar4 = UITabBarItem(title: "标题3", image: (Public .getImgView("nenu_fourth_off")), selectedImage: (Public .getImgView("nenu_service_on")))
nvc1.tabBarItem = tabbar1
nvc2.tabBarItem = tabbar2
nvc3.tabBarItem = tabbar3
nvc4.tabBarItem = tabbar4
let tc = UITabBarController()
tc.tabBar.tintColor = UIColor.init(colorLiteralRed:128.0/255.0, green:179.0/255.0, blue:255.0/255.0, alpha:1)
tc.viewControllers = [nvc1,nvc2,nvc3,nvc4]
return tc;
}
}nav.swift
import UIKit
class nav: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
let navigationTitleAttribute : NSDictionary = NSDictionary(object: UIColor.whiteColor(),forKey: NSForegroundColorAttributeName)
self.navigationBar.titleTextAttributes = navigationTitleAttribute as [NSObject : AnyObject] as? [String : AnyObject]
self.navigationBar .setBackgroundImage(UIImage(named: "4.png"), forBarMetrics: .Default)
}
}Public.swift
import UIKit
class Public: NSObject {
class func getImgView(ImgName: NSString)->UIImage{
var image:UIImage = UIImage(named: ImgName as String)!
image = image.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
return image
}
}
Swift 中定义UITabBarController
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- UITabBarController(标签栏/底部导航栏视图控制器) UITabBarController 本身并...
- 一、UITabBarController以其相关控件之间的关系 @interface UITabBarContro...
- 1.思路 最近项目中需要在tabbar中间做一个突出按钮,查了很多资料也没看到,于是按照自己的想法写了个,基...