Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make UIProgressBar programmatically in swift

I want to make UIProgressBar programmatically in swift?

what is wrong in this code?

 override func viewDidLoad() {
    super.viewDidLoad()
        let progressView = UIProgressView(progressViewStyle: .Bar)
        progressView.center = self.view.center
        progressView.frame = CGRectMake(0,0,50,20)
        progressView.translatesAutoresizingMaskIntoConstraints = false
        progressView.setProgress(0.5, animated: false)
        self.view.addSubview(progressView)
 }
like image 815
sulabh qg Avatar asked Jun 08 '16 06:06

sulabh qg


1 Answers

let progressView = UIProgressView(progressViewStyle: .Bar)
progressView.center = view.center
progressView.setProgress(0.5, animated: true)
progressView.trackTintColor = UIColor.lightGrayColor()
progressView.tintColor = UIColor.blueColor()
view.addSubview(progressView)

you need to do this type code and you can't need to set frame .

like image 135
dhiren bharadava Avatar answered Nov 02 '22 06:11

dhiren bharadava