0
如何在UIViewPropertyAnimator執行動畫過程時增加值?由於我已將運動對象設置爲運動,因此我想在屏幕上放下它的值時增加它的值,但我不確定如何將其與我的Animator鏈接。有什麼建議麼?這是我如何發起的如何在UIViewPropertyAnimator執行動畫過程時增加值?
let toTravel = CGFloat(blockSize * newInstance.distanceToTravel()) //checks how far it needs to go.
let frame = CGRect(x: x, y: startY, width: width, height: height)
super.init(frame: frame)
backgroundColor = UIColor.clear
addSubBlocksToView(grid: grid, blockSize: blockSize)
animator = UIViewPropertyAnimator(duration: 10.0, curve: .linear) { [unowned self] in
self.center.y += toTravel // need to calculate CODE this it is a static right now
}
正如你所看到的,它需要10秒鐘來旅行我計算的距離。我想跟蹤它已經通過計數器行進的每個像素(30)。