Make borderless window with darker larger shadow

蹲街弑〆低调 提交于 2019-12-08 07:37:13

问题


How to create darker and larger shadow when window becomes active in borderless window?

I subclassed NSWindow and my window becomes main window and key window but that's not helping.. shadow still small. So maybe someone knows how to fix this? I also tried invalidate shadow, but that didn't help too..

Subclassed NSWindow:

- (id)initWithContentRect:(NSRect)contentRect
            styleMask:(NSUInteger)windowStyle
              backing:(NSBackingStoreType)bufferingType
                defer:(BOOL)flag
{

    self = [super initWithContentRect: contentRect
                  styleMask: NSBorderlessWindowMask 
                    backing: NSBackingStoreBuffered
                      defer: NO];

    if(self)
    {
        [self setHasShadow:YES];

        [self setBackgroundColor:[NSColor clearColor]];
        [self setOpaque:NO];
    }   

return self;
}

回答1:


If this were my problem, I'd probably turn the shadow property off for the borderless window and then handle the shadow drawing from a display function within my NSWindow subclass (making sure to call [super display] so the various content & sub views get their own draw methods called).

Here's a potentially related question with an answer for you to consider.




回答2:


This is tied to the window's styleMask. If it is set to NSTitledWindowMask window will get a larger shadow.




回答3:


In general I think Dalmazio is correct in his observation that borderless windows have a less pronounced shadow for whatever reason. Maybe file radar with apple.



来源:https://stackoverflow.com/questions/8948228/make-borderless-window-with-darker-larger-shadow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!