简体   繁体   English

选项卡栏 Controller:切换到暗模式时的图标和 Colors

[英]Tab Bar Controller: Icon and Colors when switching to dark mode

When I switch my app to dark mode this is what happens to the tab bar.当我将应用程序切换到暗模式时,标签栏会发生这种情况。 How can i make the tapped icon fully visible in the dark mode environment?如何使点击的图标在暗模式环境中完全可见?

im using the runtime property tintColor to automatically change the color and it's set in this way我使用运行时属性 tintColor 自动更改颜色,并以这种方式设置

tintColor = Label

在此处输入图像描述

You should use the traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) function of UIView/UIViewController to detect changes in the interface environment (including changes in the user interface style).您应该使用 UIView/UIViewController 的 traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) function 来检测界面环境的变化(包括用户界面样式的变化)。 Then after checking it you can change the color of the TabBar icons depending on the selected mode by using the below:然后在检查后,您可以使用以下命令根据所选模式更改 TabBar 图标的颜色:

 UITabBar.appearance().barTintColor = #colorLiteral(red: 0.2000651062, green: 0.1960035861, blue: 0.2000851929, alpha: 1)
        UITabBar.appearance().tintColor = #colorLiteral(red: 0.2000651062, green: 0.1960035861, blue: 0.2000851929, alpha: 1)
        UITabBar.appearance().unselectedItemTintColor = #colorLiteral(red: 0.7415059209, green: 0.5448099971, blue: 0.5051562786, alpha: 1)

and you can check your colors depending on your App.您可以根据您的应用程序检查您的 colors。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM