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)を追跡したいと思います。