ios swift中的自定义进度条动画

时间:2017-04-13 11:43:50

标签: ios swift animation uiview progress-bar

我试图通过UIView制作进度条,其中包含3种颜色的图像,我希望进度条向右移动并从屏幕的左边缘平滑地重新出现。到目前为止,我已经成功地为视图设置了动画,它正在向右移动,当它到达边界时,它会消失并从左侧重新出现。但我希望它完全穿过右边框并同时从左边再次出现,就好像一半的视图穿过右边框,它应该从同一个实例的左边框重新出现。

这就是我正在尝试的。

CustomProgressView.frame = CGRect(x: 0, y: 480, width: 100, height: 20)

 UIView.animate(withDuration: 2.0, delay: 0, options: [.repeat, .curveEaseOut], animations: {

        //self.CustomProgressView.frame = CGRect(x: 420, y: 480, width: 100, height: 20)
          self.CustomProgressView.frame = CGRect(x: 420 , y: 480, width: self.CustomProgressView.frame.size.width,height: self.CustomProgressView.frame.size.height)

    }, completion: nil)

0 个答案:

没有答案