在iOS中使用核心图形上下文绘制一个圆圈 - Objective-C或Swift

use*_*474 3 objective-c cgcontext ios swift

我正以这种方式画一个圆圈:

CGContextRef contextRef = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(contextRef, 2.0);
//CGContextSetRGBFillColor(contextRef, 0, 0, 1.0, 1.0);
//CGContextSetRGBStrokeColor(contextRef, 0, 0, 1.0, 1.0);
 CGContextSetStrokeColorWithColor(contextRef, [color CGColor]);
CGRect circlePoint = (CGRectMake(coordsFinal.x, coordsFinal.y, 50.0, 50.0));

CGContextFillEllipseInRect(contextRef, circlePoint);
Run Code Online (Sandbox Code Playgroud)

我想知道怎样才能让圆圈内部变空,这样我才能看到它背后的东西.

Dru*_*erB 8

你的意思是你只想要大纲?CGContextStrokeEllipseInRect在那种情况下使用.

CGContextRef contextRef = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(contextRef, 2.0);
CGContextSetStrokeColorWithColor(contextRef, [color CGColor]);
CGRect circlePoint = (CGRectMake(coordsFinal.x, coordsFinal.y, 50.0, 50.0));

CGContextStrokeEllipseInRect(contextRef, circlePoint);
Run Code Online (Sandbox Code Playgroud)