【问题标题】:Title Bar Transparency Removes Blur标题栏透明度消除模糊
【发布时间】:2016-04-04 16:51:35
【问题描述】:

我有一个子类 NSWindow,它使用未记录的 CGSSetWindowBackgroundBlurRadius 方法来模糊透明背景。

这很好,但是我也想模糊标题栏。为了做到这一点,我可以将 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

【问题讨论】:

    标签: cocoa blur nswindow titlebar


    【解决方案1】:

    与 Apple 取得联系,显然没有办法做到这一点。

    【讨论】:

      猜你喜欢
      • 2013-06-23
      • 2010-09-30
      • 2016-11-18
      • 2016-03-10
      • 2014-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多