我正在使用一个UISnapBehavior,但它的速度太快了,我不喜欢.有没有办法减慢速度?或者换句话说:有没有办法调整物体的弹性以及它应该捕捉的点?
有没有办法让 UISnapBevahiour 只沿着线性 x 轴工作?
我想要 UISnapBehaviour 的确切行为,但不希望它在 x 和 y 轴上“摇动”到位置,而只是在 x 轴上摇动。
这是针对表格单元格的 contentView 内的 UIView 的。
Run Code Online (Sandbox Code Playgroud)// UIKitDynamics self.animator = [[UIDynamicAnimator alloc] initWithReferenceView:self]; CGPoint centerPoint = self.contentView.center; self.snapBehaviour = [[UISnapBehavior alloc] initWithItem:self.frontView snapToPoint:centerPoint]; [self.snapBehaviour setDamping:1.0f]; [self.animator addBehavior:self.snapBehaviour]; UIDynamicItemBehavior *itemBehaviour = [[UIDynamicItemBehavior alloc] initWithItems:@[self.frontView]]; itemBehaviour.elasticity = 0.0f; itemBehaviour.allowsRotation = NO; [self.animator addBehavior:itemBehaviour];