Created
January 29, 2009 16:47
-
-
Save KirinDave/54616 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (void)drawRect:(CGRect)rect { | |
| [[UIColor grayColor] setFill]; | |
| UIRectFill(rect); | |
| [[UIColor blueColor] setFill]; | |
| CGRect drawnRect = CGRectInset(rect, 20.0f, 20.0f); | |
| CGMutablePathRef path = CGPathCreateMutable(); | |
| CGPathAddRect(path, NULL, drawnRect); | |
| CGRect elipseRect = CGRectInset(drawnRect, 25.0f, 25.0f); | |
| CGPathAddEllipseInRect(path, NULL, elipseRect); | |
| CGContextRef ctx = UIGraphicsGetCurrentContext(); | |
| CGContextAddPath(ctx, path); | |
| CGContextEOFillPath(ctx); | |
| // Triangle | |
| path = CGPathCreateMutable(); | |
| float baseX = rect.size.width / 2.0f; | |
| float baseY = rect.size.height / 2.0f; | |
| float offX = 100.0f; | |
| float offY = 50.0f; | |
| NSLog(@"%f %f", baseX, baseY); | |
| CGPathMoveToPoint(path, NULL, baseX + offX, baseY + offY); | |
| CGPathAddLineToPoint(path, NULL, baseX - offX, baseY + offY ); | |
| CGPathAddLineToPoint(path, NULL, baseX, baseY - offY); | |
| CGPathAddLineToPoint(path, NULL, baseX + offX, baseY + offY); | |
| [[UIColor redColor] setFill]; | |
| CGContextAddPath(ctx, path); | |
| CGContextFillPath(ctx); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment