我正在尝试构建一个设置CFPreferences的应用程序,如下所示:
CFPreferencesSetValue((CFStringRef)@"AppleInterfaceStyle", NULL, kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost);然后发布一个通知,让系统知道它已经被更改了。
CFNotificationCenterPostNotification(CFNotificationCenterGetDistributedCenter(), (CFStringRef)@"AppleInterfaceThemeChangedNotification", NULL, NULL, YES);
[defaults setObject:@"light" forKey:@"interfaceStyle"];我在一个普通的Mac App上试过了,它不能工作,但如果我把它放在prefPane里,它就能工作。有谁有什么建议吗?
这是特定于Yosemite的,并将主题设置为light (更改菜单栏和停靠)。
发布于 2014-10-13 01:06:43
在dispatch_async中封装通知代码对我来说很有效。不过,我不知道为什么。
dispatch_async(dispatch_get_main_queue(), ^{
CFNotificationCenterPostNotification(CFNotificationCenterGetDistributedCenteR(),
(CFStringRef)@"AppleInterfaceThemeChangedNotification", NULL, NULL, YES);
});https://stackoverflow.com/questions/25056325
复制相似问题