Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 461
raulriera Avatar asked Sep 01 '14 19:09

raulriera


Video Answer


1 Answers

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.

like image 150
darren102 Avatar answered Oct 03 '22 22:10

darren102