How to do I implement a horizontal progress bar in iOS like as 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?
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.
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.
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.
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".
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
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With