3

I'm not a physics expert. However, I want to move UILable which has a dynamic height (depends on content) just like teleprompter. But when I start behaviour with magnitude 10, it starts moving but suddenly its slow down and I want continuous move up at the same speed.

Below is my code :

push = UIPushBehavior(items: [lblText], mode: .instantaneous)
push.setAngle(-.pi/2, magnitude: 10)
animator.addBehavior(push)

lblText size is 375*1500

Sunil Targe
  • 7,251
  • 5
  • 49
  • 80
  • 2
    Make sure that both your friction and resistance are zero https://developer.apple.com/documentation/uikit/uidynamicitembehavior – Josh Homann Jan 12 '19 at 17:46

1 Answers1

3

Josh is right, try adding friction and resistance. To add friction, you will have to create UIDynamicItemBehavior

let behavior = UIDynamicItemBehavior.init(items: [lblText])

Create this with the items that you need to perform your animations on.

Then you can add friction and resistance to it

behavior.friction = 0
behavior.resistance = 0

And finally add the behavior to the animator

animator.addBehavior(behavior)

Let me know if this works, happy to help.

AjinkyaSharma
  • 1,870
  • 1
  • 16
  • 26