问题
So I set up a UIProgressView to fill after 3 seconds as well as increasing the height of the bar a bit. However when it fills up, it fills diagonally as opposed to just filling from one side to the other. The bar starts in the top right corner and then expands to fill the progress view just before it ends.
This is the code I am using:
import UIKit
class LoadingScreen: UIViewController {
@IBOutlet weak var progressView: UIProgressView!
override func viewDidLoad() {
super.viewDidLoad()
UIView.animateWithDuration(3, animations: { () -> Void in
self.progressView.setProgress(1.0, animated: true)
})
progressView.transform = CGAffineTransformScale(progressView.transform, 1, 10)
}
}
Here are some screenshots:
回答1:
Coming to this rather late but I just experienced this and fixed it by changing my progressView style to .Bar. Hope that helps!
let progressView = UIProgressView(progressViewStyle: .Bar)
回答2:
It seems that the size of the progressView is incorrect.
Try to put these code in viewDidLayoutSubviews
:
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
UIView.animateWithDuration(3, animations: { () -> Void in
self.progressView.setProgress(1.0, animated: true)
})
progressView.transform = CGAffineTransformScale(progressView.transform, 1, 10)
}
来源:https://stackoverflow.com/questions/31453454/swift-uiprogressview-fills-diagonally