I wan't to resize an UIView using keyframeAnimation because it has to be synced animated with a label text as it goes down.
So I've setup the size animation
let sizeAnimation = CAKeyframeAnimation(keyPath: "transform.scale")
sizeAnimation.duration = 1.2
let animationTime = TimeInterval(1.2/Float(volumeObjects.count - 1))
// Stride is an inverted for in, it goes from volumeObjects count to 0
var sizeAnimationValuesArray = [NSValue]()
var keyTimes = [NSNumber]()
var currentKeyTime: TimeInterval = 0
for index in stride(from: volumeObjects.count - 1, to: -1, by: -1) {
let currentPercentage = CGFloat(index)/CGFloat(volumeObjects.count)
sizeAnimationValuesArray.append(NSValue(caTransform3D: CATransform3DMakeScale(1.0, currentPercentage, 1.0)))
keyTimes.append(NSNumber(value: currentKeyTime))
currentKeyTime += animationTime
}
sizeAnimation.values = sizeAnimationValuesArray
self.indicatorView.layer.add(sizeAnimation, forKey: "Bottom")
But for some reason, it doesn't work, literally nothing happens
You're not actually using the keyTimes
array for anything. You populated it with times, but you didn't assign it to the animation.