Skip to content

Instantly share code, notes, and snippets.

@peterstuart
Created July 30, 2014 14:32
Show Gist options
  • Save peterstuart/8ec6008636bbd3f37998 to your computer and use it in GitHub Desktop.
Save peterstuart/8ec6008636bbd3f37998 to your computer and use it in GitHub Desktop.
- (void)drawRect:(NSRect)dirtyRect {
CGFloat blurRadius = self.blurRadius;
NSSize shadowOffset = NSMakeSize(0, -self.blurOffset);
NSImage *circularImage = [self.image maskedCircularImageWithDiameter:self.circleDiameter];
NSRect rect = NSMakeRect(blurRadius, blurRadius + self.blurOffset, circularImage.size.width, circularImage.size.height);
NSShadow *shadow = [NSShadow new];
shadow.shadowBlurRadius = blurRadius;
shadow.shadowOffset = shadowOffset;
shadow.shadowColor = [NSColor blackColor];
[shadow set];
[circularImage drawInRect:rect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment