How to create progress bar programmatically?

别等时光非礼了梦想. 提交于 2019-12-19 11:28:45

问题


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



来源:https://stackoverflow.com/questions/3617093/how-to-create-progress-bar-programmatically

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!