Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autolayout and Facebook Pop

Is there currently a way to use the Facebook Pop framework with auto-layout or do you have to use springs and struts? I keep reading that it is possible, but I don't know what the syntax is to be able to animate a view's top constraint.

like image 695
Endama Avatar asked Jul 31 '14 20:07

Endama


1 Answers

In this case you want to animate an NSLayoutConstraint you can do the following with POP and it will animate the constraint. Note that the POPSpringAnimation is being added to the constraint itself.

NSLayoutConstraint *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. So if you want to do it on auto layout constraints you can use this constraint property.

Working with scale and other properties also works with AutoLayout so you should have no issues with getting POP to work with AutoLayout.

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

darren102