我不打算使用UIView来调整keyframeAnimation的大小,因为当标签文本下降时,它必须与标签文本同步。
所以我已经设置了尺寸动画
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")但出于某种原因,它不起作用,实际上什么都没有发生
发布于 2017-10-30 19:57:23
实际上,您没有将keyTimes数组用于任何事情。您用时间填充了它,但是没有将它分配给动画。
https://stackoverflow.com/questions/47023205
复制相似问题