繁体   English   中英

暗模式macOS Sierra

[英]Dark Mode macOS Sierra

我正在尝试找到一种在OS Sierra中将模式从亮模式更改为暗模式的方法。 我有此更改设置:

CFPreferencesSetValue((CFStringRef)@"AppleInterfaceStyle", @"Dark", kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost);

这是要告诉OS进行更改:

dispatch_async(dispatch_get_main_queue(),
               ^{CFNotificationCenterPostNotification(CFNotificationCenterGetDistributedCenter(), (CFStringRef)@"AppleInterfaceThemeChangedNotification", NULL, NULL, true);}
               );

但是,仅更改停靠栏,而不更改通知和菜单栏。 感谢您的任何帮助,您可以提供。

编辑:如果有人有插入此功能的按键列表,将很有帮助。 在Apple文档上似乎找不到它。

我发现了一种实现这一目标的方法。 使用applescript,更改主题非常容易(且安全)。

脚本如下:

tell application "System Events"
    tell appearance preferences to set dark mode to not dark mode
end tell

编译脚本,将其添加到xcodeproject中,并对如何在目标c中运行applescript进行更多研究。

暂无
暂无

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

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