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)
        }
  • 相关阅读:
    unity, 显示像素图,以及iOS下像素图变模糊解决办法
    unity, iOS集成微信
    unity, PlayerPrefs.GetInt(key,defaultValue)
    unity, 对于Debug.Log输出的log,可以双击定位到代码
    unity, UGUI Image shader
    unity, use particleSystem with UGUI
    unity, UGUI Text fadeIn
    unity, write/read txt file
    unity, get Canvas Scaler referenceResolution
    unity, change parent and keep localPosition or worlPosition
  • 原文地址:https://www.cnblogs.com/sgxx/p/5828736.html
Copyright © 2011-2022 走看看