0
當用戶點擊屏幕時,應在用戶觸摸的位置繪製圓圈。我的代碼有什麼問題?當用戶觸摸時產生圓圈
{
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);
}
爲什麼會發生什麼? – trojanfoe 2013-02-26 11:54:36