How to create progress bar programmatically?

2019-02-20 05:35发布

问题:

I created a view with a progress bar with an IBOutlet. Whenever I rotate the view to landscape mode, it is not rotated. So, I need to create the progress bar programmatically.

How can I do this?

回答1:

UIProgressView *progressView = [[UIProgressView alloc] init];
progressView.frame = CGRectMake(100,100,100,20);
[self.view addSubview:progressView];

Should get you started.

I would read up on views and view controllers in Apple's documentation. The View Programming Guide for iPhone OS goes into quite a bit of detail for what you want to do. If you have not read the iPhone Application Programming Guide and the iPhone Development Guide I would do so first.

All of these documents are available on developer.apple.com, and also in the help system of Xcode.



回答2:

You can rotate the progress bar to vertical by the below code:

progressView.transform= CGAffineTransformMakeRotation( M_PI * 0.5 );



回答3:

you have to set the property of size in IB then is't work fine see in below image

this work for both orientations