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)
        }
  • 相关阅读:
    第四十七课、父子间的冲突
    第四十六课、继承中的构造与析构
    第四十五课、不同的继承方式
    第四十四课、继承中的访问级别
    第四十三课、继承的概念和意义
    第四十二课、类型转换函数(下)
    第四十一课、类型转化构造函数(上)
    暴力大法好
    HideProcess
    Hduacm—5497
  • 原文地址:https://www.cnblogs.com/sgxx/p/5828736.html
Copyright © 2011-2022 走看看