ios - 使用 POP 框架的 UIView 动画在同一操作中放大和缩小

标签 ios animation uiview facebook-pop

我正在使用 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/

相关文章:

iphone - 如何实现appflow的欢迎页面动画

iphone - iOS 5 iPhone 4 Interface Builder 突然间我的所有 View 都变得透明了。怎么修?

iphone - UITabBarController 上的 AddSubView

cocoa-touch - 初始化自定义 UITableViewCell

ios - 在 viewDidLoad() 中使用 CLLocationManager() 可以防止 MKMapView 被拖动或缩放

ios - UITableView indexPath 弄乱了我的数组

iphone - 如何使旋转 UIView 的方法工作多次

javascript - 进入 Mobile Safari 后返回 iPad Webapp

ios - iOS 中的交互式视频 : Is it possible to trigger specific actions in code by tapping discrete parts in the video?

animation - 是否可以为 react-router-native 应用动画?