2016-12-03 128 views
1

我试图找到一种方法来在OS Sierra中将模式从浅色变为黑色。我有这样的更改设置:暗模式macOS塞拉利昂

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

这告诉OS挑上的变化:

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

但是,只有码头的变化,而不是通知和菜单栏。感谢您的任何帮助,您可以提供。

编辑:如果任何人有一个插入this function,这将是有益的关键列表。似乎无法在苹果文档中找到它。

回答

1

我发现了一点点的方法来完成这个。使用applescript,更改主题非常简单(并且安全)。

脚本如下:

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

编译脚本,将它添加到xcodeproject做如何运行目标C里面的AppleScript了些研究。

相关问题