-1

I have created a popup in swift using UIView and I want to bounce it when displaying, but I don't know how to do that. I want to make the same effect as seen below:

enter image description here

mag_zbc
  • 6,801
  • 14
  • 40
  • 62
Besart
  • 309
  • 1
  • 4
  • 22

1 Answers1

1

You should use UIView.animate with usingSpringWithDamping and initialSpringVelocity parameters. Eg:

// Change position of view
UIView.animate(withDuration: 1.0, delay: 0.0, usingSpringWithDamping: 1.0, initialSpringVelocity: 0.0, options: [], animations: {
    // Call layoutIfNeeded()
})

Or you can change view's position in animation completion block. But it's not recommended.

Rodion Kuskov
  • 146
  • 1
  • 5