具有 POP 框架的 UIView 动画在同一动作中增长和收缩

UIView Animation with POP framework grow and shrink in same action

我正在使用 POP 动画框架。我想点击一个 UIButton 并让它增长 5%,然后收缩回原来的大小。我可以让增长或收缩工作,但由于我没有使用框架,我不知道如何在一个动作中同时发生。

动画代码如下。我从附加到各种按钮的 IBAction 发送此代码。下面的代码只是让它成长。

-(void)popAnimationGrowAndShrink:(UIButton*)sender{

    const CGRect originalSize = sender.frame;

    POPSpringAnimation *animGrow = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerBounds];
    POPSpringAnimation *animShrink = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerBounds];
    animGrow.toValue = [NSValue valueWithCGRect:CGRectMake(0, 0, sender.frame.size.width * 1.1, sender.frame.size.height *1.1)];
    animShrink.toValue = [NSValue valueWithCGRect:originalSize];
    animGrow.springSpeed = 5;
    animGrow.springBounciness = 10;
    animShrink.springSpeed = 5;
    animShrink.springBounciness = 10;

    [sender.layer pop_addAnimation:animGrow forKey:@"grow"];
    [sender.layer pop_addAnimation:animShrink forKey:@"shrink"];
}

不用写那么多代码,框架很简单

-(void)popAnimationGrowAndShrink:(UIButton*)sender{

   UIButton *btn=(UIButton*)sender;
   POPSpringAnimation *sprintAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewScaleXY];
   sprintAnimation.velocity = [NSValue valueWithCGPoint:CGPointMake(8, 8)];
  sprintAnimation.springBounciness = 20.f;
   [self.btn pop_addAnimation:sprintAnimation forKey:@"bounceAnim"];
}