0
文書化されていないCGSSetWindowBackgroundBlurRadiusメソッドを使用して透明な背景をぼかすサブクラスのNSWindowがあります。タイトルバーの透明度がぼかしを取り除きます
これはうまくいきますが、タイトルバーをぼかすこともできます。これを行うには、NSFullSizeContentViewWindowMaskマスクを既存のスタイルにORできます。これで、タイトルバーが透明なビューに変更されますが、ぼかし効果は失われます。どのように私はこれについて行くことができるの任意のアイデア?
#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