【发布时间】:2020-12-23 14:23:45
【问题描述】:
我正在开发一个 macOS 应用程序,我想让用户能够在明暗模式之间切换。
对于 iOS 应用程序,这可以通过简单地覆盖 UserInterfaceStyle 的 UIWindow 来完成。像这样:
window.overrideUserInterfaceStyle = .dark //.light
问题:NSWindow 没有 UserInterfaceStyle 属性。
我已经尝试设置NSAppearance
window.appearance = NSAppearance(appearanceNamed: NSAppearance.Name.aqua, bundle: nil)
没有成功。它返回给我一条错误消息:“RunTimeThemeRefForBundleIdentifierAndName() 找不到带有标识符的捆绑包中的 NSAppearanceNameAqua.car:...”
我被困住了。你有什么想法吗?
Here would be a solution for iOS
谢谢!
【问题讨论】: