2015-07-20 65 views
0

创建动画序列我非常新的IOS的动画节目。 我想上的UIButton创建这样的动画:在0.3秒上的UIButton IOS

  1. 第一比例放大,
  2. 然后按比例缩小恢复正常0.2秒。

有人能告诉我或指引我走向正确的方向吗?

回答

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

您还可以在它使用本地动画脉冲。

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)