Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
以编程方式迭代UIProgressView动画-Swift_Swift_Animation_Textview_Uiprogressview - Fatal编程技术网

以编程方式迭代UIProgressView动画-Swift

以编程方式迭代UIProgressView动画-Swift,swift,animation,textview,uiprogressview,Swift,Animation,Textview,Uiprogressview,我已经设置了progressView和textView,我希望progressView设置其进度条的动画,并在完成后重置进度条,同时更改textView并再次启动动画 这就是我所尝试的: var iterator : Int = 0 fileprivate func setUpAnimation(){ switch iterator { case 0: interactiveShowTextView.text = quotesArray[itera

我已经设置了progressView和textView,我希望progressView设置其进度条的动画,并在完成后重置进度条,同时更改textView并再次启动动画

这就是我所尝试的:

var iterator : Int = 0


fileprivate func setUpAnimation(){
    
    switch iterator {
    case 0:

        interactiveShowTextView.text = quotesArray[iterator]
        animateAndIterate()

    case 1:

        interactiveShowTextView.text = quotesArray[iterator]
        animateAndIterate()

    case 2:


        interactiveShowTextView.text = quotesArray[iterator]
        animateAndIterate()

    default:

            self.iterator = 0
            self.setUpAnimation()

}
}

只有当迭代器为0时,它才能在开始时正常工作,但当我将它迭代到1时,textView开始疯狂地不断更改textView文本。
我真的不知道为什么

进度条的长度是多少?0-1或0-10这是0-1@jawadali这是什么setupAnimation@jawadAli它与包含开关的函数相同。每当动画结束时,我都会再次调用它,我基本上是调用相同的函数来更改迭代器,以便switch可以检测迭代器的值并按照相应的方式进行操作。。我想你走错了方向…进度条的长度是多少?0-1或0-10这是0-1@jawadali这是什么setupAnimation@jawadAli它与包含开关的函数相同。每当动画结束时,我都会再次调用它,我基本上是调用相同的函数来更改迭代器,以便switch可以检测迭代器的值并按照相应的方式进行操作。。我认为你走错了方向。。。
fileprivate func animateAndIterate(){
    UIView.animate(withDuration: 0.0, animations: {
        self.progressBar.layoutIfNeeded()
    }, completion: { finished in
        self.progressBar.progress = 1.0

        UIView.animate(withDuration: 5, delay: 0.0, options: [.curveLinear], animations: {
            self.progressBar.layoutIfNeeded()
        }, completion: { finished in
            print("animation completed")
            self.iterator += 1
            self.setUpAnimation()

        })
    })
}