如何使用pop或CoreAnimation更改动画的起点或锚点

时间:2015-04-21 13:23:50

标签: ios animation core-animation facebook-pop

以下代码启动缩放动画,并从UIButton的中心沿XY展开。如何从左侧开始或frame.origin.x = 0

    POPSpringAnimation *anim = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerBounds];
    anim.fromValue = [NSValue valueWithCGRect:CGRectMake(signupButton.frame.origin.x,
                                                         signupButton.frame.origin.y,
                                                         0,
                                                         signupButton.frame.size.height)];
    anim.toValue = [NSValue valueWithCGRect:signupButton.frame];
    [anim setValue:@"progressBar" forKey:@"animName"];
    anim.delegate = self;

//    I tried to set anchor point but without any luck
//    signupButton.layer.anchorPoint = CGPointMake(150, signupButton.frame.origin.y);

    [signupButton.layer pop_addAnimation:anim forKey:@"signupButton"];

1 个答案:

答案 0 :(得分:1)

您正在设置边界的动画,但是传入框架。你想要动画边界是正确的。

所以,我认为这将是正确的代码。

cout << size << endl; // Prints out size which is now set to maximum positive value.