我正在使用 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"];
}
关于ios - 使用 POP 框架的 UIView 动画在同一操作中放大和缩小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35053019/