怎么样,这款自定义的Tab Bar漂亮吧!
接下来就教大家如何快速集成
依然是几句代码就可以搞定
首先,将我Demo中的TabBar文件夹拖入到你的工程中。
之后在AppDelegate中创建
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
/*初始化window*/
self.window = UIWindow.init(frame: UIScreen.mainScreen().bounds)
self.window!.backgroundColor = UIColor.whiteColor()
self.window!.makeKeyAndVisible()
/*创建一个自定义TabBar控制器*/
let tabController = FNFoldingTabBarController()
tabController.tabBarBgColor = UIColor.clearColor()
tabController.title = "自定义TabBar"
/*初始化4个视图(在这之前先创建4个UIViewController类)*/
let vc0 = ViewController0()
let vc1 = ViewController1()
let vc2 = ViewController2()
let vc3 = ViewController3()
/*将4个视图添加到TabBar控制器上*/
tabController.fn_viewControllers = [vc0,vc1,vc2,vc3]
/*创建一个导航控制器*/
let nav = UINavigationController(rootViewController: tabController)
nav.navigationBar.barTintColor =
UIColor(red: 102/255, green: 204/255, blue: 204/255, alpha: 1)
nav.navigationBar.titleTextAttributes =
[NSForegroundColorAttributeName: UIColor.whiteColor()]
/*设置启动项*/
self.window?.rootViewController = nav
self.window?.makeKeyAndVisible()
return true
}
好了,就是这么简单
喜欢的话,别忘了点击上方的关注按钮,更多精彩尽在我的简书博客
最后附上Demo地址https://pan.baidu.com/s/1o7HrYY2