0

ユーザーが を使用して画面に描いたパスを描画したいUIPanGestureRecognizer

次の関数を使用していますが、結果はありません。

どこが間違っているのか教えてください。

- (void)pan:(UIPanGestureRecognizer *)sender{

     [[UIColor greenColor]set];
     CGContextRef context=UIGraphicsGetCurrentContext();
     CGContextSetLineWidth(context, 1.0f);


     if (sender.state==UIGestureRecognizerStateBegan) {
         CGContextMoveToPoint(context, [sender locationInView:self.view].x, [sender locationInView:self.view].y);
         NSLog(@"touch phase began");
     }

     CGContextAddLineToPoint(context, [sender locationInView:self.view].x, [sender locationInView:self.view].y);

     if (sender.state==UIGestureRecognizerStateEnded)
         CGContextStrokePath(context);
}

前もって感謝します

4

1 に答える 1

1

UIPanGestureRecognizerで描画を行うdraw-line-with-gestureリンクを参照してください。

お役に立てば幸いです。

于 2012-08-30T08:58:20.977 に答える