如何在模拟器上启用暗模式?

如何在模拟器上启用暗模式?

问题描述:

我想弄清楚如何在 Xcode 模拟器上打开新的暗模式.据我所知,它会在天黑时在真实设备上自行开启.有没有办法在模拟器上触发这个?

I’m trying to figure out how to turn on the new dark mode on the Xcode simulator. As far as I know it turns on by itself on real devices when it’s dark. Is there a way to trigger this on the simulator?

在 Xcode 11 中有两种方法可以激活暗模式.这两种方法都需要您手动操作,并且不会根据时间自动执行.

There are two ways to activate the dark mode in Xcode 11. Both require you manual steps and are not automatic depending on the time.

1.环境覆盖

首选的是在 Xcode 中使用 Environment Overrides.在 Xcode 中的模拟器上运行应用程序时,调试器控件中调试内存图"和模拟位置"旁边会出现一个按钮.您会在那里找到一个用于启用暗模式以及选择文本大小和其他辅助功能设置的菜单.

The preferred one is to use the Environment Overrides inside Xcode. When running the App on the simulator in Xcode appears a button in the debugger controls next to 'Debug Memory Graph' and 'Simulate Location'. There you will find a menu for enabling dark mode, as well as choose text size and other accessibility settings.

2.模拟器设置

或者,您可以进入模拟器上的设置应用程序:

Alternatively you can go inside the Settings App on the simulator:

设置 > 开发者 > 深色外观

Settings > Developer > Dark Appearance