首页 > 解决方案 > UIProgressView 向后进展

问题描述

当语言是 LTR 时,我有这个进度条可以完美运行。但是当语言是 RTL 时开始倒退然后前进。

func AnimateTimerPath(inViewController vc:UIViewController,Duration:TimeInterval){
    
    DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
        
        self.BarAnimation = UIViewPropertyAnimator.init(duration: Duration, curve: .linear) {
            self.ProgressBar.setProgress(1, animated: true)
            self.ProgressBar.layoutIfNeeded()
        }
        self.BarAnimation.startAnimation()
    }
}

private func BuildTimeBar(inViewController vc:UIViewController){
    
    ProgressBar.frame = CGRect(x: .zero, y: .zero,
                               width: vc.view.frame.width-40, height: 4)
    
    ProgressBar.trackTintColor = .lightGray
    ProgressBar.progressTintColor = .white
    ProgressBar.center = CGPoint(x: vc.view.frame.midX, y: 80)
    ProgressBar.setProgress(0, animated: false)
    ProgressBar.progressViewStyle = .default
    
    if Locale.preferredLanguages[0] == "he" || Locale.preferredLanguages[0] == "ar"{
            self.ProgressBar.transform = .identity.rotated(by: .pi)
    }
    
    vc.view.addSubview(ProgressBar)
}

我使用UIViewPropertyAnimator暂停中间动画。它使用UIView.animate

这就是发生的事情

标签: iosswift

解决方案


推荐阅读