当用户单击屏幕时,应在用户触摸的位置绘制一个圆圈。我的代码有什么问题?
{
BOOL _touchHasBegun;
CGPoint whereUserClicked;
float pointWhereUserClickedX;
float pointWhereUserClickedY;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
_touchHasBegun = YES;
}
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(context, 0, 0, 225, 1);
CGContextSetRGBFillColor(context, 0, 0, 255, 1);
CGRect rectangle = CGRectMake(pointWhereUserClickedX, pointWhereUserClickedY, 10, 10);
CGContextStrokeEllipseInRect(context, rectangle);
}