Skip to content

Instantly share code, notes, and snippets.

@Serjip
Last active March 16, 2023 02:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Serjip/c24853dc06e613ab9574 to your computer and use it in GitHub Desktop.
Save Serjip/c24853dc06e613ab9574 to your computer and use it in GitHub Desktop.
//Original http://cocoasnippets.io/cocoa/ui/nswindow/coregraphics/2014/02/27/translucent-nswindow-with-blurred-background.html
// one more solution http://stackoverflow.com/questions/11174918/how-to-get-window-with-semi-transparent-blurred-background
typedef void * CGSConnection;
extern OSStatus CGSSetWindowBackgroundBlurRadius(CGSConnection connection, NSInteger windowNumber, int radius);
extern CGSConnection CGSDefaultConnectionForThread();
- (void)enableBlurForWindow:(NSWindow *)window
{
[window setOpaque:NO];
window.backgroundColor = [NSColor colorWithCalibratedWhite:1.0 alpha:0.5];
CGSConnection connection = CGSDefaultConnectionForThread();
CGSSetWindowBackgroundBlurRadius(connection, [window windowNumber], 20);
}
@TheMrugraj
Copy link

Dont use this solution. My App rejected due to use of this API.

"The use of non-public APIs can lead to a poor user experience should these APIs change in the future, and is therefore not permitted. The app includes : CGSSetWindowBackgroundBlurRadius from the framework '/System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics'."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment