其中 key_pop 是一个UILabel
UIView.animate(withDuration: 1, animations: {() -> Void in print("do annimat"); key_pop.frame.origin.y += 50 key_pop.frame.size.height -= 50; }){(finished) -> Void in key_pop.isHidden = true; }
在执行动画过程中 可以 移除 动画, 但是该 方法不会阻止 执行 finished 里面的 代码 。
func pauseAnimate(layer:CALayer){ layer.removeAllAnimations() } pauseAnimate(layer: key_pop.layer);
** transform 旋转、缩放、位移 动画
扫描二维码关注公众号,回复:
230587 查看本文章
UIView.animate(withDuration: 0.25, animations: {() -> Void in //缩放比例X倍数 0.5 = 0.5倍, 5 = 5倍 self.v.transform = CGAffineTransform.init(scaleX: 0.5, y: 0.5); //旋转 self.v.transform = CGAffineTransform.init(rotationAngle: 50) //位移 self.v.transform = CGAffineTransform.init(translationX: 50, y: 50) }){(finished) -> Void in }