gpt4 book ai didi

android - iOS 中类似 Android 的水平线性进度条

转载 作者:可可西里 更新时间:2023-11-01 04:00:00 24 4
gpt4 key购买 nike

如何在 iOS 中像 Android 一样实现水平进度条。

Progressbar in iOS like Android

我尝试了以下方法,并找到了类似deteminate 的解决方案。

func startSendPickUpRequestShakeTimer () {

if self.movingViewTimer == nil {
self.movingViewTimer = Timer.scheduledTimer(
timeInterval: TimeInterval(movingViewSpeed),
target : self,
selector : #selector(self.startAnimating),
userInfo : nil,
repeats : true)
}
}

func startAnimating() {

let movingViewX = movingView.frame.minX >= view.frame.maxX ? 0-movingView.frame.width-forwardX:movingView.frame.minX + forwardX

self.movingView.frame = CGRect(x: movingViewX, y: movingView.frame.minY, width: movingView.frame.width, height: moviewViewHeight)

}

但是我该如何实现其他方法,或者是否有任何好的资源可以做到这一点?

最佳答案

我为 ios 中的不确定进度编写了此扩展。也许这可以帮助

extension UIProgressView{
private struct Holder {
static var _progressFull:Bool = false
static var _completeLoading:Bool = false;
}

var progressFull:Bool {
get {
return Holder._progressFull
}
set(newValue) {
Holder._progressFull = newValue
}
}

var completeLoading:Bool {
get {
return Holder._completeLoading
}
set(newValue) {
Holder._completeLoading = newValue
}
}

func animateProgress(){
if(completeLoading){
return
}
UIView.animate(withDuration: 1, animations: {
self.setProgress(self.progressFull ? 1.0 : 0.0, animated: true)
})

progressFull = !progressFull;

DispatchQueue.main.asyncAfter(deadline: .now() + 1.2) {
self.animateProgress();
}
}

func startIndefinateProgress(){
isHidden = false
completeLoading = false
animateProgress()
}

func stopIndefinateProgress(){
completeLoading = true
isHidden = true
}
}

关于android - iOS 中类似 Android 的水平线性进度条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44234635/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com