Migrating from `POPSpringAnimation` to native iOS framework in Swift 4

Viewed 514

I am working on an old project and want to get rid of POP framework I am sure that any animation can be done with native iOS framework.

Here is the old code:

POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewFrame];
springAnimation.toValue = [NSValue valueWithCGRect:rect];
springAnimation.velocity = [NSValue valueWithCGRect:CGRectMake(springVelocity, springVelocity, 0, 0)];
springAnimation.springBounciness = springBounciness;
springAnimation.springSpeed = springSpeed;
[springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
    if (finished) {
         // cool code here
    }
}];

[self.selectedViewController.view pop_addAnimation:springAnimation forKey:@"springAnimation"];

What I have tried:

[UIView animateWithDuration:1.0
                      delay:0
     usingSpringWithDamping:springBounciness
      initialSpringVelocity:springVelocity
                    options:UIViewAnimationOptionCurveEaseInOut animations:^{
                        self.selectedViewController.view.frame = rect;
} completion:^(BOOL finished) {
    // cool code here
}];

But I dont get the same result, and some question rises:

  1. is springBounciness in pop equivalent to usingSpringWithDamping ?
  2. What is equivalent of springSpeed in UIView animation ?
  3. what about the duration, what is the duration of POPSpringAnimation ?

Edit: About the third question I found an issue in Github.

If UIView is not the way to go can that be done using Core Animation or any other iOS native animation framework ?

1 Answers
Related