0
터치 제스처에서 직사각형이나 삼각형을 그릴 때 문제가 있습니다. 다음은 코드입니다.아이폰에 그림 그리기
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:self];
// move the cannon to the touched location
x = location.x;
[self moveCannon];
[self setNeedsDisplay];
}
-(void) moveCannon
{
// draw the cannot as a triangle for right now
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, 20.0f, 100.0f);
CGPathAddLineToPoint(path, NULL, 50.0f, 100.0f);
CGPathAddLineToPoint(path, NULL, 50.0f, 20.0f);
CGPathAddLineToPoint(path, NULL, 50.0f, 100.0f);
CGPathCloseSubpath(path);
CGContextSetFillColorWithColor(self.context, [UIColor redColor].CGColor);
CGContextAddPath(self.context, path);
CGContextFillPath(self.context);
}
무엇이 누락 되었습니까?
내 맞춤법을 제대로 호출하지 않아서 문제가 발견되었습니다. – azamsharp