标题栏透明度消除模糊
Title Bar Transparency Removes Blur
我有一个子类 NSWindow,它使用未记录的 CGSSetWindowBackgroundBlurRadius 方法来模糊透明背景。
这工作正常,但我还想模糊标题栏。为了做到这一点,我可以将 NSFullSizeContentViewWindowMask 掩码用于现有样式。这成功地将标题栏更改为透明视图,但模糊效果丢失了!我有什么想法可以解决这个问题吗?
#import "TransparentNSWindow.h"
@implementation TransparentNSWindow
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 colorWithCalibratedRed:255./255. green:255./255. blue:255./255. alpha:0.4];
CGSConnection connection = CGSDefaultConnectionForThread();
CGSSetWindowBackgroundBlurRadius(connection, [window windowNumber], 20);
}
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag {
NSUInteger currentStyle = [self styleMask];
NSUInteger style = NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask;
self = [super initWithContentRect:contentRect styleMask :style backing :NSBackingStoreBuffered defer:NO ];
if (self)
{
[self setOpaque:NO];
[self setHasShadow:NO];
self.titlebarAppearsTransparent = true;
self.titleVisibility = true;
// Uncommenting this line results in a transparent title bar but no blur
//self.styleMask |= NSFullSizeContentViewWindowMask;
[self enableBlurForWindow:self];
}
return self;
}
@end
已与 Apple 取得联系,但显然无法做到这一点。
我有一个子类 NSWindow,它使用未记录的 CGSSetWindowBackgroundBlurRadius 方法来模糊透明背景。
这工作正常,但我还想模糊标题栏。为了做到这一点,我可以将 NSFullSizeContentViewWindowMask 掩码用于现有样式。这成功地将标题栏更改为透明视图,但模糊效果丢失了!我有什么想法可以解决这个问题吗?
#import "TransparentNSWindow.h"
@implementation TransparentNSWindow
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 colorWithCalibratedRed:255./255. green:255./255. blue:255./255. alpha:0.4];
CGSConnection connection = CGSDefaultConnectionForThread();
CGSSetWindowBackgroundBlurRadius(connection, [window windowNumber], 20);
}
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag {
NSUInteger currentStyle = [self styleMask];
NSUInteger style = NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask;
self = [super initWithContentRect:contentRect styleMask :style backing :NSBackingStoreBuffered defer:NO ];
if (self)
{
[self setOpaque:NO];
[self setHasShadow:NO];
self.titlebarAppearsTransparent = true;
self.titleVisibility = true;
// Uncommenting this line results in a transparent title bar but no blur
//self.styleMask |= NSFullSizeContentViewWindowMask;
[self enableBlurForWindow:self];
}
return self;
}
@end
已与 Apple 取得联系,但显然无法做到这一点。