建个UIView延展, 方便所有UIView子类都可以使用
extension UIView {
func zoomLoopAnimation() {
let animation = CABasicAnimation(keyPath: "transform.scale")
animation.duration = 0.8 // 设置动画时间
animation.repeatCount = 100000
animation.autoreverses = true
animation.fromValue = 1
animation.toValue = 1.1
animation.isRemovedOnCompletion = false // 这个属性是为了离开页面后动画仍然存在
self.layer.add(animation, forKey: "scale-layer")
}
}
网友评论