var newSpeed = speed
var newProgress = progress
newSpeed += 2/Double(duration)
newProgress += newSpeed/Double(duration)
if progress >= 1 {
return
}
UIView.animate(withDuration: 1, delay: 0, options: .curveLinear, animations: {
self.ringProgressView.progress = newProgress
print("The newProgress is: \(newProgress), and the new speed is \(newSpeed)")
}) { (hello) in
if (newSpeed*100).rounded()/100 == 1.0 {
newProgress += newSpeed/Double(duration)
UIView.animate(withDuration: 1, delay: 0, options: .curveLinear, animations: {
self.ringProgressView.progress = newProgress
print("The newProgress is: \(newProgress), and the new speed is \(newSpeed)")
}) { (hello) in
self.animation(duration: duration, speed: newSpeed, progress: newProgress)
}
} else {
self.animation(duration: duration, speed: newSpeed, progress: newProgress)
}
}
UIView.animate(withDuration: TimeInterval(duration), delay: 0, options: UIViewAnimationOptions.curveLinear, animations: {
moveFaster = 180
self.ringProgressView.progress += Double((360 + moveFaster) / 360 / duration)
})
随着时间的推移,我正在做的是尝试加速ringProgressView.progress。
基本上,我需要做的是给函数提供一个秒变量(即30秒),然后通过加速,使ringProgressView.progress结束(达到1.0),开始时变慢,结束时变快。