當爲ProgressView使用動畫時,如果我讓動畫用完,但如果我嘗試再次運行此代碼,則它工作得很好在動畫仍在繼續時,它將100%添加到當前酒吧並通過酒吧。圖像應該更合理地解釋情況。Swift Progress視圖動畫使酒吧進一步超過100%
進展開始於1.0(100%)
Progress is half-way through
The code was ran again, resulting in the progress going above 100%, although it uses the correct amount of time to finish.
這裏使用的代碼:
self.progressView.setProgress(1.0, animated: false)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
UIView.animate(withDuration: 10, delay: 0, options: [.beginFromCurrentState, .allowUserInteraction], animations: { [unowned self] in
self.progressView.setProgress(0, animated: true)
})
}
提前感謝!
是否有可能在你正在運行的代碼的其他部分(雖然設置下一個問題)的東西是無意中更改progressView框架或約束? – DonMag