Search code examples
swiftmacos-mojave

Make sidebar widget transparent on macOS Mojave


I have two apps for macOS Mojave that come with an extension for the sidebar. I have noticed that the app extension looks different in the Widget Simulator and the sidebar. When the app runs in the Widget Simulator, the background has some transparency. When I run the app normally, there is no such transparency. I have attached two screenshots:

Screenshot of the notification area. You can see the calculator app and my app below - no transparency

This is how my app looks in the simulator

As you can see, the app has no transparency (compare to the calculator app of macOS). The second screenshot shows the app running in the simulator with transparency.

Are there any options that I have to set to make it transparent? Is there a new type if NSView descendant? The title bar is also different, so I don't think it is enough to simply set the background color to "clear". The latest version of the app is built for 10.14 only, so I don't care if the solution is only available for macOS Mojave.

I have checked, that the widget inherits the appearance of the super view/window. I did not change any other properties. I also tried using a NSVisualEffectView with various settings, but this also did not solve the problem.

Regards


Solution

  • I just found a solution in the Apple Developer forums:

    Apple Developer Forum

    In the info.plist file of the extension, there is a section called NSExtension. In there, the NSExtensionAttributes/NSExtensionPointVersion had to be incremented (was 2.0, now is 3.0).

    Now the app extension looks nice:

    Info.plist Settings