【问题标题】:Swift: Change the image tint color of tab bar?Swift:更改标签栏的图像色调颜色?
【发布时间】:2015-07-11 09:03:31
【问题描述】:

我以编程方式创建了 tabBarController,我想更改该选项卡包含的图像(而不是条形图)的色调颜色。谁能告诉我如何在 Swift 中做到这一点?

【问题讨论】:

    标签: ios swift uiimage uitabbarcontroller tintcolor


    【解决方案1】:

    以上所有答案都在这里我正在分享以使用故事板检查器实现这一目标

    选择您的标签栏转到检查器并将图像色调更改为您相应的颜色以供参考附加图像

    【讨论】:

      【解决方案2】:

      转到 AppDelegate.swift 文件。在“应用程序:didFinishLaunchingWithOptions”中写:

      UITabBar.appearance().unselectedItemTintColor = UIColor.red
      

      【讨论】:

        【解决方案3】:

        另一个很好的解决方案:

        添加名为“tintColor”的运行时颜色属性

        它会改变图像的色调以及标题的色调。

        【讨论】:

          【解决方案4】:

          在您的“应用程序:didFinishLaunchingWithOptions”中

          (window?.rootViewController as! UITabBarController).tabBar.tintColor = UIColor.red
          

          或使用外观委托。

          UITabBar.appearance().tintColor = UIColor.red
          

          【讨论】:

          • 而不是 .tintColor = ... 尝试使用 .barTintColor =
          • 它只改变选中状态的颜色
          猜你喜欢
          • 2014-12-23
          • 2013-06-11
          • 1970-01-01
          • 1970-01-01
          • 2013-09-18
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多