【发布时间】:2015-07-20 04:29:37
【问题描述】:
我对 IOS 动画编程很陌生。 我想在 UIButton 上创建这样的动画:
- 0.3 秒内首次放大,
- 然后在 0.2 秒内缩小到正常值。
有人可以告诉我或引导我走向正确的方向吗?
【问题讨论】:
标签: ios objective-c animation uibutton
我对 IOS 动画编程很陌生。 我想在 UIButton 上创建这样的动画:
有人可以告诉我或引导我走向正确的方向吗?
【问题讨论】:
标签: ios objective-c animation uibutton
示例代码:
[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)
【讨论】: