【问题标题】:Create a sequence of Animation on UIButton IOS在 UIButton IOS 上创建动画序列
【发布时间】:2015-07-20 04:29:37
【问题描述】:

我对 IOS 动画编程很陌生。 我想在 UIButton 上创建这样的动画:

  1. 0.3 秒内首次放大,
  2. 然后在 0.2 秒内缩小到正常值。

有人可以告诉我或引导我走向正确的方向吗?

【问题讨论】:

    标签: ios objective-c animation uibutton


    【解决方案1】:

    示例代码:

    [UIView animateKeyframesWithDuration:0.5 delay:0.0 options:UIViewKeyframeAnimationOptionRepeat animations:^{
    
        [UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.60 animations:^{
            myButton.transform = CGAffineTransformMakeScale(2.0, 2.0);
        }];
        [UIView addKeyframeWithRelativeStartTime:0.60 relativeDuration:0.40 animations:^{
            myButton.transform = CGAffineTransformIdentity;
        }];
        } completion:^(BOOL finished) {
        NSLog(@"Completed");
    }];
    

    【讨论】:

      【解决方案2】:

      你也可以在里面使用原生动画脉冲。

      var pulseAnimation:CABasicAnimation = CABasicAnimation(keyPath: "transform.scale");
              pulseAnimation.duration = 1.0;
              pulseAnimation.toValue = NSNumber(float: 1.5);
              pulseAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut);
              pulseAnimation.autoreverses = true;
              pulseAnimation.repeatCount = FLT_MAX;
              self.Outlet.layer.addAnimation(pulseAnimation, forKey: nil)
      

      【讨论】:

        猜你喜欢
        • 2015-06-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-01-06
        相关资源
        最近更新 更多