Skip to content

Instantly share code, notes, and snippets.

@joerick
Created April 28, 2015 10:35
Show Gist options
  • Save joerick/d52f188b926835b1f655 to your computer and use it in GitHub Desktop.
Save joerick/d52f188b926835b1f655 to your computer and use it in GitHub Desktop.
-[NSWindow _cornerMask] implementation for hosting NSVisualEffectView
- (NSImage *)_cornerMask
{
CGFloat radius = 4.0;
CGFloat dimension = 2 * radius + 1;
NSSize size = NSMakeSize(dimension, dimension);
NSImage *image = [NSImage imageWithSize:size flipped:NO drawingHandler:^BOOL(NSRect dstRect) {
NSBezierPath *bezierPath = [NSBezierPath bezierPathWithRoundedRect:dstRect xRadius:radius yRadius:radius];
[[NSColor blackColor] set];
[bezierPath fill];
return YES;
}];
image.capInsets = NSEdgeInsetsMake(radius, radius, radius, radius);
image.resizingMode = NSImageResizingModeStretch;
return image;
}
- (NSImage *)cornerMask
{
return [self _cornerMask];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment