簡體   English   中英

在UIButton IOS上創建動畫序列

[英]Create a sequence of Animation on UIButton IOS

我對IOS動畫編程非常陌生。 我想在UIButton上創建這樣的動畫:

  1. 首先在0.3秒內放大
  2. 然后在0.2秒內縮小到正常水平。

有人可以告訴我或指引我正確的方向嗎?

樣例代碼:

[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");
}];

您也可以在其中使用本機動畫脈沖。

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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM