简体   繁体   English

暗模式不会在 Xcode 中切换到暗模式背景

[英]Dark mode does not switch to a Dark mode background in Xcode

I have set up different backgrounds for ' Light/Dark Appearance '我为“ Light/Dark Appearance ”设置了不同的背景

在此处输入图像描述

But when switching between Light/Dark mode within Xcode , my background always uses image from ' Any/Light Appearance '.但是在Xcode 中的Light/Dark 模式之间切换时,我的背景总是使用来自“ Any/Light Appearance ”的图像。 Only colours set for icons changes accordingly.只有为图标设置的颜色会相应更改。

在此处输入图像描述

FYI: I'm switching between Light/Dark mode using Interface Style option.仅供参考:我正在使用界面样式选项在亮/暗模式之间切换。

在此处输入图像描述

Can someone please advice what I'm missing on?有人可以建议我缺少什么吗? It's all new to me.这对我来说都是新的。

I think it is an Xcode bug.我认为这是一个 Xcode 错误。 You can confirm it by changing your setting in the iOS Simulator.您可以通过更改 iOS 模拟器中的设置来确认。

Go to Settings -> Developer -> Dark Appearance转到设置 -> 开发人员 -> 深色外观

I think you might need to uncheck the Resizing checkbox and set the Scales property to Single Scale.我认为您可能需要取消选中 Resizing 复选框并将 Scales 属性设置为 Single Scale。 It worked for me.它对我有用。

在此处输入图片说明

将图像设置为渲染为原始图像

I think it's an Xcode (latest version) bug.我认为这是一个 Xcode(最新版本)错误。

If you run it on your phone, you won't have this problem.如果你在手机上运行它,你就不会有这个问题。 Meaning settings are correct.含义设置正确。

In Simulator it's working fine.在模拟器中它工作正常。 One can confirm by toggling the Appearance from feature menu of the simulator.可以通过从模拟器的功能菜单中切换外观来确认。

这似乎是一个 Xcode 错误,但是当您尝试在模拟器或物理设备上运行它时,假设您处于黑暗模式,它应该可以完美运行。

By unchecking the Preserve Vector Data option 1 , one can see the change in the background when switching between the modes from interface styles 2 .通过取消选中“保留矢量数据”选项1 ,您可以在界面样式2的模式之间切换时看到背景的变化。

But I noticed that if you leave the option selected and test it on the simulator, it works perfectly fine there.但我注意到,如果您选择该选项并在模拟器上测试它,它在那里工作得非常好。 Hence I feel it's an Xcode bug too.因此我觉得这也是一个 Xcode 错误。

在此处输入图片说明

在此处输入图片说明

The Xcode Bug is still here, Xcode storyboard appearance switcher does not work, it only works in the simulator. Xcode Bug 仍然存在,Xcode storyboard 外观切换器不起作用,它只能在模拟器中运行。
You can change the simulator device appearance: Settings> Developer> Dark Appearance.您可以更改模拟器设备外观:设置 > 开发人员 > 深色外观。


Happy coding.快乐编码。

On my physical device iPhone 8 iOS 14.6 dark Mode doesn't work.在我的物理设备上,iPhone 8 iOS 14.6 暗模式不起作用。 traitCollectionDidChange not get called after switching to dark mode.切换到暗模式后不会调用 traitCollectionDidChange。 On my iPhone 12 iOS 15.x, and some testers it works.在我的 iPhone 12 iOS 15.x 和一些测试人员上它可以工作。 No Solution i tried worked.我试过的没有解决方案有效。 Also i got some other weird UI bugs aswell on my iPhone 8.我的 iPhone 8 上还有一些其他奇怪的 UI 错误。

Hope its just an Xcode Bug.希望它只是一个 Xcode 错误。

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

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