简体   繁体   English

减缓UISnapBehavior

[英]Slow down UISnapBehavior

I am using a UISnapBehavior but it is snapping too quickly for my liking. 我正在使用一个UISnapBehavior,但它的速度太快了,我不喜欢。 Is there a way to slow it down? 有没有办法减慢速度? Or in other words: is there a way to adjust the elasticity of the object with the point where it should snap to? 或者换句话说:有没有办法调整物体的弹性以及它应该捕捉的点?

I was able to solve this by attaching the view to a UIDynamicItemBehavior as well and setting the resistance property. 我能够通过将视图附加到UIDynamicItemBehavior并设置resistance属性来解决这个问题。

UIDynamicItemBehavior *dynamicItemBehavior = [[UIDynamicItemBehavior alloc] initWithItems:@[ view ]];
dynamicItemBehavior.resistance = 100;
[animator addBehavior:dynamicItemBehavior];

Try setting the behaviour's damping property to a number > 1.0. 尝试将行为的damping属性设置为> 1.0的数字。 The header says damping should remain in [0.0, 1.0] however values larger than 1.0 seem to work fine. 标题表示damping应保持在[0.0, 1.0]但是大于1.0的值似乎可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM