iosfacebook-pop

Animate constraints using Facebook pop?


I was able to animate a constraint change using

[UIView animateWithDuration:0.5
                      delay:0.5
     usingSpringWithDamping:0.7
      initialSpringVelocity:0.7
                    options:0
                 animations:^{
                     [self.closeButton layoutIfNeeded];
                 } completion:NULL];

But I was under the impression that this could also be done using the Facebook POP library. Can anyone point me in the right direction to finding out how?

Thank you


Solution

  • In this case you want to animate an NSLayoutConstraint you can do the following with POP and it will animate the constraint.

    constraint // this is an NSLayoutConstraint that is applied to some view
    
    POPSpringAnimation *layoutAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayoutConstraintConstant];
    layoutAnimation.springSpeed = 20.0f;
    layoutAnimation.springBounciness = 15.0f;
    layoutAnimation.toValue = @(value to go too);
    [constraint pop_addAnimation:layoutAnimation forKey:@"detailsContainerWidthAnimate"];
    

    The main property to use is the kPOPLayoutConstraintConstant as shown above.