Search code examples
macoswidgetmacos-sierra

Sierra Notification Center widgets background colour


Notification Center in Sierra has a new, light background colour compared with Yosemite and El Cap. My widget, however, still shows the old, dark style, even when I rebuild with the new SDK.

The view has appearance set to "Inherited (Vibrant Dark)". Changing that to "Aqua" seems to have no effect.

Is it possible to change third party widgets to look the same as Apple's? I notice all the other third party widgets I look the same.


Solution

  • You need to set the value of NSExtensionPointVersion to 2.0 in your Today extension's Info.plist to get the new appearance:

    <key>NSExtension</key>
    <dict>
        <key>NSExtensionAttributes</key>
        <dict>
            <key>NSExtensionPointVersion</key>
            <string>2.0</string>
        </dict>
    </dict>
    

    The last I checked this was not documented anywhere, but if you create a new Today extension using Xcode 8 it should add this for you, confirming it is the correct approach. (I actually figured it out by inspecting the contents of Apple's own Today extensions.)

    One thing worth mentioning is that older versions of macOS will still have the dark appearance, so if your extension is backwards compatible you'll need to adjust your content to suit the background color. In your Today extension's main view controller you can check for the dark appearance like this:

    NSString *appearance = self.parentViewController.view.effectiveAppearance.name;
    BOOL legacyDarkBackground = ([appearance isEqualToString:NSAppearanceNameVibrantDark]);