iOS單手指旋轉View

tags:    時間:2013-12-03 18:40:14
高手給一段單手指能旋轉View的代碼
------解決方案--------------------
在UIPanGestureRecognizer的處理函數裡面設置view的transform
view.transform = CGAffineTransformMakeRotation(radian);
------解決方案--------------------
參考它的實現 
https://www.cocoacontrols.com/controls/ktonefingerrotationgesturerecognizer
------解決方案--------------------
UIPanGestureRecognizer *pansGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePans:)];
    [pansGesture setMaximumNumberOfTouches:1];
    
    [self.rotationView addGestureRecognizer:pansGesture];
- (void)handlePans:(UIPanGestureRecognizer *)sender
{
    CGPoint translationPoint = [sender velocityInView:self.view];
    self.rotationView.transform = CGAffineTransformMakeRotation(sender.view.center.x+translationPoint.x);
}

推薦閱讀文章

Bookmark the permalink ,來源:互聯網