我只为任意视图设置了一个图层动画,但它没有任何效果。任何人都知道为什么它不起作用?
static func pulseView(v: UIView) {
let animation = CABasicAnimation(keyPath: "shadowColor")
animation.fromValue = UIColor.yellow.cgColor
animation.toValue = UIColor.green.cgColor
let animation2 = CABasicAnimation(keyPath: "shadowOpacity")
animation2.fromValue = 0.5
animation2.toValue = 1
let agr = CAAnimationGroup()
agr.duration = 0.5
agr.repeatCount = 2
agr.autoreverses = true
agr.animations = [animation, animation2]
v.layer.borderWidth = 5
v.layer.add(agr, forKey: "shadowOpacity")
}