我对IOS动画编程很陌生。 我想在UIButton上创建这样的动画:
有人可以向我展示或引导我走向正确的方向吗?
答案 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");
}];
答案 1 :(得分: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)