I have two animations that I want to chain into group.
They look like this :
func animate(circle: UIView) {
var animations = [CABasicAnimation]()
let opacityAnimation = CABasicAnimation(keyPath: "opacity")
opacityAnimation.repeatCount = Float.infinity
opacityAnimation.autoreverses = true
opacityAnimation.fromValue = 0.0
opacityAnimation.toValue = 0.40
animations.append(opacityAnimation)
let scaleAnimation = CABasicAnimation(keyPath: "transform.scale")
scaleAnimation.repeatCount = Float.infinity
scaleAnimation.autoreverses = true
scaleAnimation.fromValue = 0.8
scaleAnimation.toValue = 1
animations.append(scaleAnimation)
let group = CAAnimationGroup()
group.duration = 1.4
group.repeatCount = FLT_MAX
group.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
group.animations = animations
circle.layer.add(group, forKey: nil)
}
Is there a way I can set separate duration to first animation and separate to second ? For example, I want 3 seconds for opacityAnimation
and 1 second for scaleAnimation
How can I do this ?