现在,我有一个UIPushBehavior
我在视图上使用的,根据用户用UIPanGestureRecognizer
. 它有效,但我的问题是视图旋转了一个荒谬的量......就像它连接到跑车的轮胎一样。
这就是我附加的方式UIPushBehavior
:
else if (panGestureRecognizer.state == UIGestureRecognizerStateEnded) {
[self.animator removeBehavior:self.panAttachmentBehavior];
self.pushBehavior = [[UIPushBehavior alloc] initWithItems:@[self.imageView] mode:UIPushBehaviorModeInstantaneous];
[self.pushBehavior setTargetOffsetFromCenter:centerOffset forItem:self.imageView];
self.pushBehavior.active = YES;
CGPoint velocity = [panGestureRecognizer velocityInView:self.view];
CGFloat area = CGRectGetWidth(self.imageView.bounds) * CGRectGetHeight(self.imageView.bounds);
CGFloat UIKitNewtonScaling = 1000000.0;
CGFloat scaling = area / UIKitNewtonScaling;
CGVector pushDirection = CGVectorMake(velocity.x * scaling, velocity.y * scaling);
self.pushBehavior.pushDirection = pushDirection;
[self.animator addBehavior:self.pushBehavior];
}
我不知道我应该改变什么来更多地操纵它。速度和一切都很完美,我只是不想让它旋转得那么荒谬。