- (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextMoveToPoint(context, 0, 0); CGContextAddRect(context,CGRectMake(100, 100, 200 , 150)); CGContextMoveToPoint(context, 200, 175); CGContextAddArc(context, 200, 175, 50,-3.14/2.0,3.14/2.0, 0); CGContextAddLineToPoint(context, 200 , 175); CGContextMoveToPoint(context, 160, 175); CGContextAddArc(context, 160, 175, 50,-5.0*3.14/6.0,-7.0*3.14/6.0, 1); CGContextAddLineToPoint(context, 160, 175); //画边框 //CGContextStrokePath(context); //设置填充色 [[UIColor redColor] setFill]; [[UIColor colorWithRed:0.6 green:0.4 blue:0.5 alpha:0.5] setFill]; //设置边框颜色 [[UIColor blackColor] setStroke]; //[[UIColor greenColor] set]; //EVEN-ODD, 奇偶规则填充 CGContextDrawPath(context, kCGPathEOFillStroke); //控制点 CGContextAddCurveToPoint(context, 50, 0, 50, 200, 100, 100); CGContextAddQuadCurveToPoint(context, 150, 0, 200, 100); CGContextStrokePath(context); } @end
时间: 2024-12-28 02:09:16