このコードをよりスムーズにするにはどうすればよいですか。三角形を描画しようとしていますが、ワンタッチ(タッチを移動)でサイズを変更したいと思います。これが私のコードです:
-(id)initWithPoint:(CGPoint )point withFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
givenPoint = point;
}
return self;
}
- (void)drawRect:(CGRect)rect
{
// Drawing code
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(ctx, 0, 0, 0, 1);
CGPoint points[6] = { CGPointMake(10, 10), CGPointMake(50, 10),
CGPointMake(50, 10), givenPoint,
givenPoint, CGPointMake(10, 10) };
CGContextSetRGBFillColor(ctx, 255, 255, 255, 1);
CGContextStrokeLineSegments(ctx, points, 6);
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
UIView *view = touch.view;
[view removeFromSuperview];
TailView *tailView = [[TailView alloc] initWithPoint:CGPointMake(location.x, location.y) withFrame:CGRectMake(100, 100, location.x + 40, location.y + 40)];
tailView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:tailView];
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(move:)];
[panRecognizer setMinimumNumberOfTouches:1];
[panRecognizer setMaximumNumberOfTouches:1];
[panRecognizer setDelegate:self];
[tailView addGestureRecognizer:panRecognizer];
}