Last active
June 12, 2024 12:53
-
-
Save Serjip/c24853dc06e613ab9574 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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); | |
} |
I was having linking issues in ObjC++, so to help anyone in the future, make sure you have -framework CoreGraphics and if ur in ObjC++ declare the functions as extern "C"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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'."