一、以storyboard的方式自定义tabBar
let _width = self.view.frame.width
let _height = self.view.frame.height - 49
self.homeVc = UIStoryboard.init(name: "Home", bundle: nil).instantiateViewControllerWithIdentifier("home_sid") as? NavigationController
self.homeVc!.view.frame = CGRectMake(0, 0, _width, _height)
//注册controller
self.addChildViewController(self.homeVc!)
self.discoverVc = UIStoryboard.init(name: "Discover", bundle: nil).instantiateViewControllerWithIdentifier("discover_sid") as? NavigationController
self.discoverVc!.view.frame = CGRectMake(0, 0, _width, _height)
self.addChildViewController(self.discoverVc!)
self.messageVc = UIStoryboard.init(name: "Message", bundle: nil).instantiateViewControllerWithIdentifier("message_sid") as? NavigationController
self.messageVc!.view.frame = CGRectMake(0, 0, _width, _height)
self.addChildViewController(self.messageVc!)
self.profileVc = UIStoryboard.init(name: "Profile", bundle: nil).instantiateViewControllerWithIdentifier("profile_sid") as? NavigationController
self.profileVc?.view.frame = CGRectMake(0, 0, _width, _height)
self.addChildViewController(self.profileVc!)
self.view.addSubview(self.homeVc!.view)
网友评论