2011-02-07 30 views

答えて

0

ここは回転するコードです。具体的には

 
-(void)LongPress:(UILongPressGestureRecognizer *)gesture { 

    CGPoint p = [gesture locationInView:self.view]; 

    CGPoint zero; 
    zero.x = self.view.bounds.size.width/2.0; 
    zero.y = self.view.bounds.size.height/2.0; 

    CGPoint newPoint; 

    newPoint.x = p.x - zero.x; 
    newPoint.y = zero.y - p.y; 
    CGFloat angle; 
    angle = atan2(newPoint.x, newPoint.y); 
    self.myButton.transform = CGAffineTransformRotate(CGAffineTransformIdentity, angle); 

} 
0

、その後、あなたが可能なカスタムrotateView、:

1: "touchesBegan" のデリゲートメソッドでは、指のinitialPointinitialAngleを取得します。

2: "touchesMoved" の間に、指のnewPointを取得:

CGPoint newPoint = [[touches anyObject] locationInView:self]; 
    [self pushTouchPoint:thePoint date:[NSDate date]]; 
    double angleDif = [self angleForPoint:newPoint] - [self angleForPoint:initialPoint]; 
    self.angle = initialAngle + angleDif; 
    [[imageView layer] setTransform:CATransform3DMakeRotation(angle, 0, 0, 1)]; 

3:最後に、 "touchesEnded" で、あなたは最終的AngularVelocityを計算することができます。

混乱しているものがあれば、詳しくは書き留めてください。

関連する問題