关于如何在Swift中实现这个漂亮的库,文档还不清楚
我可以导入MRProgress并显示模糊的overlayView,但我无法获得更新进度
//尝试一个:无法查看显示或参数更改 ```
var overlay = MRProgressOverlayView()
upload.uploadProgress(closure: { //Get Progress
progress in
print(progress.fractionCompleted) // double
progressFloat = Float(progress.fractionCompleted) // float
if progress.fractionCompleted < 1 {
// Here are some options but they are not working
self.overlay.mode = .determinateCircular
self.overlay.frame = CGRect(x: 50, y: 50, width: 100, height: 80)
self.overlay.setTintColor(UIColor.blue)
self.overlay.titleLabelText = "Uploading!"
self.overlay.show(true)
self.overlay.progress = progressFloat
self.overlay.setProgress(progressFloat, animated: true)
}
if progress.fractionCompleted == 1 {
print("Completed")
// remove progress
self.overlay.dismiss(true)
}
```
//尝试两个:View出现但setProgress抛出错误
MRProgressOverlayView.showOverlayAdded(to: self.view, title: "Uploading", mode: .determinateCircular, animated: true)
MRProgress.setProgress(floatProgress, true)
// error
// Use of instance member 'setProgress' on type 'MRProgressOverlayView'; did you mean to use a value of type 'MRProgressOverlayView' instead?
来自src的
/**
Change progress animated.
The animation will be always linear.
@param progress The new progress value.
@param animated Specify YES to animate the change or NO if you do not want the change to be animated.
*/
open func setProgress(_ progress: Float, animated: Bool)
谁能告诉我如何使用这个漂亮的图书馆? 最后,有1500+代表的人可以为MRProgress添加标签
答案 0 :(得分:0)
解决了
let overlay = MRProgressOverlayView.showOverlayAdded(to: self.view, title: "Uploading", mode: .determinateCircular, animated: true)
upload.uploadProgress(closure: { //Get Progress
progress in
print(progress.fractionCompleted)
self.progressFloat = Float(progress.fractionCompleted)
if progress.fractionCompleted < 1 {
overlay?.setProgress(self.progressFloat, animated: true)
}
if progress.fractionCompleted == 1 {
print("Completed")
overlay?.dismiss(true)
}
})