Skip to content

Instantly share code, notes, and snippets.

@Nub
Created September 8, 2011 19:27
Show Gist options
  • Select an option

  • Save Nub/1204432 to your computer and use it in GitHub Desktop.

Select an option

Save Nub/1204432 to your computer and use it in GitHub Desktop.
- (void)drawRect:(NSRect)dirtyRect
{
NSBezierPath *path = [self _popoverBezierPathWithRect:[self bounds]];
CGContextRef ref = [[NSGraphicsContext currentContext] graphicsPort];
//Fix blurred edges by offsetting by half a pixel
CGContextTranslateCTM(ref, 0.5, 0.5);
[self.color set];
//Gradient and extra stroke for HUD mimic
if(self.appearance == NSPopoverAppearanceHUD){
NSGradient *borderGradient =
[[[NSGradient alloc]
initWithColorsAndLocations:
[NSColor colorWithCalibratedWhite:0.65 alpha:0.85],0.0,
[NSColor colorWithCalibratedWhite:0.15 alpha:0.85],0.08, nil]
autorelease];
[borderGradient drawInBezierPath:path angle:-90];
[path setLineWidth:1];
[self.hudStroke set];
[path strokeInside];
}else
[path fill];//Default fill
[path setLineWidth:_borderWidth];
[self.borderColor set];
[path stroke];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment