繁体   English   中英

带有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"];
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM