Skip to content

Instantly share code, notes, and snippets.

@tomisacat
Created December 4, 2014 07:55
Show Gist options
  • Save tomisacat/ac690939d9c02ce1dbb0 to your computer and use it in GitHub Desktop.
Save tomisacat/ac690939d9c02ce1dbb0 to your computer and use it in GitHub Desktop.
clear a circle/ellipse area like CGContextClearRect to clear a rect area
- (void)drawRect:(CGRect)rect
{
CGContextRef con = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(con, [UIColor grayColor].CGColor);
CGContextFillRect(con, rect);
CGContextAddEllipseInRect(con, self.circle); // self.circle is a property of CGRect
CGContextClip(con);
CGContextClearRect(con, self.circle);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment