【问题标题】:UIViewPropertyAnimator position resetUIViewPropertyAnimator 位置重置
【发布时间】:2019-12-10 11:38:36
【问题描述】:

我有一个小问题。我正在尝试像 Instagram 一样创建动画进度条。它在所有情况下都能正常工作,除非我想展示上一个项目。断点说当我切换到上一个项目时, UIViewPropertyAnimator 位置保持在 .end 状态,因此它立即调用其完成并“返回”到下一个项目。所以我的问题是 - 当动画师完成它的工作时,如何将它的位置重置回 .start 然后切换下一个项目?

【问题讨论】:

    标签: position progress-bar uiviewpropertyanimator


    【解决方案1】:

    问题与之前调用的函数有关。在移动到下一个或上一个项目之前,我调用了应该通过 for_in 循环更新所有 UIProgressView 对象的函数。所以当上一个item出现在屏幕上的时候,这个item的UIProgressView仍然是.progress = 1.0,UIViewPropertyAnimator什么都没有,所以调用completion block,切换下一个item。

    fillProgress(bars: currentStoryItem)
    let duration = story.files[currentStoryItem].duration
    DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
            self.progressBars[self.currentStoryItem].startFillingAnimation(with: duration)
    }
    

    asyncAfter 救了我的命)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-15
      相关资源
      最近更新 更多