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?
Asked
Active
Viewed 2,242 times
2 Answers
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
-
Can you post a code snippet for this? I'm doing the same thing but not seeing an affect on speed of snap... – Alfie Hanssen Jan 14 '14 at 21:09
-
Ah! Nevermind, I was using values between 0 and 1, values over 1 do the trick – Alfie Hanssen Jan 14 '14 at 21:10
-
ya @AlfieHanssen, I'm using values of 50 and 100 right now in my app – drewag Jan 15 '14 at 00:26
-
This makes sense but for some reason it didn't work for me. – matt Aug 27 '22 at 02:24
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
-