9

I am using a UISnapBehavior but it is snapping too quickly for my liking. 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?

drewag
  • 93,393
  • 28
  • 139
  • 128

2 Answers2

15

I was able to solve this by attaching the view to a UIDynamicItemBehavior as well and setting the resistance property.

UIDynamicItemBehavior *dynamicItemBehavior = [[UIDynamicItemBehavior alloc] initWithItems:@[ view ]];
dynamicItemBehavior.resistance = 100;
[animator addBehavior:dynamicItemBehavior];
Kyle Clegg
  • 38,547
  • 26
  • 130
  • 141
drewag
  • 93,393
  • 28
  • 139
  • 128
3

Try setting the behaviour's damping property to a number > 1.0. The header says damping should remain in [0.0, 1.0] however values larger than 1.0 seem to work fine.

Rhythmic Fistman
  • 34,352
  • 5
  • 87
  • 159
  • This may be the best way if you only want to affect the snap behavior without affecting other physics of the item being snapped. For example, if you have a velocity on the item and set the resistance high, velocity too will have less of an effect. However, sadly, when setting damping, things get screwy/wonky with the snapbehavior and I wonder if it's a bug. – Arjun Mehta Mar 05 '14 at 01:55
  • Thanks, snapping with damping 10 looks nice for me – Andriy Zymenko May 31 '16 at 07:57