Swift 自定义tabBar

一、以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)
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 仿映客tabbar 创建一个继承自UIView的自定义类 CustomTabBar.swift 创建继承自UITa...
    Lucifer_rcy阅读 804评论 0 1
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,251评论 4 61
  • 亲爱的喵,如果有一天我需要你来照顾,你也会像我宠你那样宠我吧! 小时候一边唱着“一个老丁头,欠我俩榴榴,我说三天还...
    一场大雪阅读 259评论 0 0
  • 窗外 晴空万里 蓝天白云编织出 绚丽的风景 探出头去 还是不够尽兴 转身 开门 噔噔噔跑下楼去 拉开大门 正要拥抱...
    紫郁0720阅读 258评论 5 4
  • 修改postgresql.conf postgresql.conf存放位置在/etc/postgresql/9.x...
    我的名字叫浩仔阅读 4,922评论 0 0