Autolayout和Facebook Pop

End*_*ama 7 uiviewanimation ios facebook-pop

目前有一种方法可以使用Facebook Pop框架进行自动布局,还是必须使用弹簧和支柱?我一直在阅读它是可能的,但我不知道语法是什么能够为视图的顶部约束设置动画.

dar*_*102 21

在这种情况下,您希望为NSLayoutConstraint设置动画,您可以使用POP执行以下操作,它将为约束设置动画.请注意,POPSpringAnimation正被添加到约束本身.

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"];
Run Code Online (Sandbox Code Playgroud)

要使用的主要属性是kPOPLayoutConstraintConstant,如上所示.因此,如果您想在自动布局约束上执行此操作,则可以使用此约束属性.

使用缩放和其他属性也适用于AutoLayout,因此您不应该让POP与AutoLayout一起使用.