Justin Boo
Justin Boo

Reputation: 10198

Make borderless window with darker larger shadow

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;
}

Upvotes: 3

Views: 2255

Answers (3)

Matt
Matt

Reputation: 203

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.

Upvotes: 1

Justin Boo
Justin Boo

Reputation: 10198

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

Upvotes: 2

Michael Dautermann
Michael Dautermann

Reputation: 89509

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.

Upvotes: 1

Related Questions