Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Horizontal Linear Progress Bar like Android in iOS

How to do I implement a horizontal progress bar in iOS like as Android.

Progressbar in iOS like Android

I have tried the following, and found a solution like 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)

}

But how can I implement the others, or is there any good resource to do that?

like image 257
Litle Dev Avatar asked May 29 '17 04:05

Litle Dev


People also ask

How do you make a horizontal progress bar?

In Android, by default a progress bar will be displayed as a spinning wheel but If we want it to be displayed as a horizontal bar then we need to use style attribute as horizontal. It mainly use the “android. widget. ProgressBar” class.

What are the different types of progress bars?

There are 2 types of progress bars: determinate and indeterminate. The former is used when the amount of information that needs to be loaded is detectable. The latter is used when the system is unsure how much needs to be loaded or how long it will take.

What are types of progress bar in Android?

Progress bar supports two modes to represent progress: determinate, and indeterminate. For a visual overview of the difference between determinate and indeterminate progress modes, see Progress & activity.

How do I make a custom progress bar?

Customizing a ProgressBar requires defining the attribute or properties for the background and progress of your progress bar. You can do this in the XML file or in the Activity (at run time). @hirengamit res is "Resource".


1 Answers

I had coded this extension for indetermined progress in ios. Maybe this can help

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
    }
}
like image 118
Kamran Bashir Avatar answered Oct 16 '22 23:10

Kamran Bashir