zoukankan      html  css  js  c++  java
  • Swift开发之 使用系统的TabbarController

    使用系统的tabbar解决图片的问题.
    用sb使用系统的tabbar,弄好后发现图片始终是蓝色的,并非原来的图片,后经上网查资料,问问同事,有了以下的这些代码,做个标记.
    AppDelegate中
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    initTabBarSelectedItem()
    return true
    }
    func initTabBarSelectedItem()
    {
    var rootController = self.window?

    .rootViewController as UITabBarController
    var tabBar = rootController.tabBar

        var homeItem = tabBar.items?

    [0] as UITabBarItem var selectedImg = UIImage(named: "首页")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) if homeItem.tag == 100 { homeItem.selectedImage = selectedImg homeItem.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.redColor(),NSFontAttributeName:UIFont.systemFontOfSize(14)], forState: UIControlState.Normal) } var orderItem = tabBar.items?[1] as UITabBarItem var orderItemImg = UIImage(named: "订单")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) if orderItem.tag == 101 { orderItem.selectedImage = orderItemImg orderItem.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.redColor()], forState: UIControlState.Selected) } var releaseItem = tabBar.items?

    [2] as UITabBarItem var releaseItemImg = UIImage(named: "公布")?

    .imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) if releaseItem.tag == 102 { releaseItem.selectedImage = releaseItemImg releaseItem.image = releaseItemImg releaseItem.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.redColor()], forState: UIControlState.Selected) } var myItem = tabBar.items?[3] as UITabBarItem var myItemImg = UIImage(named: "我的")?

    .imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) if myItem.tag == 103 { myItem.selectedImage = myItemImg myItem.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.redColor()], forState: UIControlState.Selected) } }

  • 相关阅读:
    phpexcel表的一些设置
    14的路 MySQL的btree索引和hash索引的区别
    mysql导入导出sql文件
    jq的form验证
    Intellij IDEA 创建Web项目并在Tomcat中部署运行
    IntelliJ Idea常用快捷键
    12个JavaScript技巧【转】
    JFinal 源码知识点
    JFinal record类型数据在前台获取
    用JS获取地址栏参数的方法
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/5339040.html
Copyright © 2011-2022 走看看