zoukankan      html  css  js  c++  java
  • 标签控制器UITabBarController

    (一)定义:与导航控制器类似,标签控制器也是一个容器类。不用的是,这个不存在层级关系。你控制器有多少个ViewController,就会一直存在这么多个。不会被释放。

    (二)UIBarButtonItem是一个模型,来控制整体TabBar样式。

    (三)基本实现:

     ///  这里设置初始启动后,有四个页面
            addChildViewController(HMHomeTableViewController(), title: "首页", imageName: "tabbar_home")
            addChildViewController(HMMessageTableViewController(), title: "消息", imageName: "tabbar_message_center")
            addChildViewController(HMDiscoverTableViewController(), title: "发现", imageName: "tabbar_discover")
            addChildViewController(HMProfileTableViewController(), title: "", imageName: "tabbar_profile")
     ///  添加四个子控制器
        ///
        ///  - parameter childController: 控制器名称
        ///  - parameter imageName:       tabBarItem图片
        ///  - parameter titleName:       tabBarItem名称
        func addChildViewController(childController: UIViewController , title: String, imageName: String) {
            // 设置颜色
            // 修改成自己的   
            childController.tabBarItem = HMTabBarItem()
            childController.tabBarItem.setTitleTextAttributes([NSFontAttributeName:UIFont.systemFontOfSize(10)], forState: .Normal)
            childController.tabBarItem.setTitleTextAttributes([NSFontAttributeName:UIFont.systemFontOfSize(22)], forState: .Selected)
            childController.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.orangeColor()], forState: .Selected)
            childController.tabBarItem.title = title
            childController.tabBarItem.image = UIImage(named: imageName)?.imageWithRenderingMode(.AlwaysOriginal)
            childController.tabBarItem.selectedImage = UIImage(named:"(imageName)_selected")?.imageWithRenderingMode(.AlwaysOriginal)
            let nav = HMNavgationController(rootViewController: childController)
            childController.navigationItem.title = title
            addChildViewController(nav)
        }
  • 相关阅读:
    jquery:class选择器(父子关系)
    jquery:跳转网页
    jquery:获得当前点击对象 : $(this)
    jquery:向后台提交数组
    03 适配器 代理 外观 装饰者
    02 工厂模式
    01 单例模式 Singleton
    设计模式概论与原则 & UML类图
    06 JDBC & ORM
    05 注解与反射 & JVM
  • 原文地址:https://www.cnblogs.com/sgxx/p/5828736.html
Copyright © 2011-2022 走看看