注:该实例来自网络,现以swif2.x重写。取自互联网,还以互联网。
要掌握ios,自定义TabBar是非常重要的,放眼现在的ios应用,几乎都有自定义TabBarController
项目地址:https://github.com/MoneyMore/CustomTabBarController
附送一个比较好的github教程
http://www.bootcss.com/p/git-guide/
这里还是大致讲解一下吧。
1、首先自定义一个tabbar的xib和对应的类,添加好约束

2、初始化自定义的tabbar,并且隐藏系统的tabbar
/**
*初始化tabbar
*/
func customTabBar() {
self.tabBar.hidden = true
var array = NSBundle.mainBundle().loadNibNamed("CustomTabBar", owner: self, options: nil)
tabBarView = array[0] as? CustomTabBar
tabBarView?.delegate = self
tabBarView?.btn_home.selected = true
tabBarView?.frame = CGRect(x: 0, y: self.view.frame.height-49, width: self.view.frame.width, height: 49)
self.view.addSubview(tabBarView!)
//实例化是否隐藏tabbar的代理
homeVC?.hiddenTabBar = self
}
总结:其实写过之后就觉得很简单了,详情看代码吧



网友评论