1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| - (void)drawRect:(CGRect)rect { CGFloat width = rect.size.width; CGFloat height = rect.size.height; CGFloat radius = (width + height) * 0.05;
CGContextRef context = UIGraphicsGetCurrentContext(); CGContextMoveToPoint(context, radius, 0);
CGContextAddLineToPoint(context, width - radius, 0); CGContextAddArc(context, width - radius, radius, radius, -0.5 * M_PI, 0.0, 0);
CGContextAddLineToPoint(context, width, height - radius); CGContextAddArc(context, width - radius, height - radius, radius, 0.0, 0.5 * M_PI, 0);
CGContextAddLineToPoint(context, radius, height); CGContextAddArc(context, radius, height - radius, radius, 0.5 * M_PI, M_PI, 0);
CGContextAddLineToPoint(context, 0, radius); CGContextAddArc(context, radius, radius, radius, M_PI, 1.5 * M_PI, 0);
CGContextClosePath(context); CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 0.5); CGContextDrawPath(context, kCGPathFill); }
|