先看效果图
代码如下
CGContextRef contextRef = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(contextRef, 1.0f, 1.0f, 1.0f, 1);
CGContextSetLineWidth(contextRef, 2.0f);
CGFloat componets[] = {0.0f,0.0f,0.0f,1.0f};
CGFloat componets1[] = {1.0f,1.0f,1.0f,1.0f};
CGContextSetFillColor(contextRef, componets);
CGContextMoveToPoint(contextRef,160, 175);
CGContextAddArc(contextRef, 160.0f, 175.0f, 125.0f, 0.0f*(M_PI/180), 180.0f*(M_PI/180), 1);
CGContextFillPath(contextRef);
CGContextSetFillColor(contextRef, componets);
CGContextFillEllipseInRect(contextRef, CGRectMake(66.25, 142.5, 62.5, 62.5));
CGContextSetFillColor(contextRef, componets);
CGContextMoveToPoint(contextRef, 222.5, 175);
CGContextAddArc(contextRef, 222.5, 175, 62.5, 0, 180*(M_PI/180), 0);
CGContextFillPath(contextRef);
CGContextSetFillColor(contextRef, componets1);
CGContextMoveToPoint(contextRef,160, 175);
CGContextAddArc(contextRef, 160.0f, 175.0f, 125.0f, 0.0f*(M_PI/180), 180.0f*(M_PI/180), 0);
CGContextFillPath(contextRef);
CGContextSetFillColor(contextRef, componets1);
CGContextMoveToPoint(contextRef, 97.5, 175);
CGContextAddArc(contextRef, 97.5, 175, 62.5, 0, 180*(M_PI/180), 1);
CGContextFillPath(contextRef);
CGContextSetFillColor(contextRef, componets);
CGContextFillEllipseInRect(contextRef, CGRectMake(66.25, 142.5, 62.5, 62.5));
CGContextSetFillColor(contextRef, componets);
CGContextMoveToPoint(contextRef, 222.5, 175);
CGContextAddArc(contextRef, 222.5, 175, 62.5, 0, 180*(M_PI/180), 0);
CGContextFillPath(contextRef);
CGContextSetFillColor(contextRef, componets1);
CGContextFillEllipseInRect(contextRef, CGRectMake(190.25, 142.5, 62.5, 62.5));
转载于:https://blog.51cto.com/demidroid/979430