iOS progressview的简单使用
head 代码。。
- #import <UIKit/UIKit.h>
- @interface ViewController : UIViewController
- {
- UIProgressView *progressview;
- UIProgressView *progressviewbar;
- NSTimer *timer;
- }
- @property(retain,nonatomic)
- IBOutlet UIProgressView *progressview;
- @property(retain,nonatomic)
- IBOutlet UIProgressView *progressviewbar;
- -(IBAction)startprogress:(id)sender;
- -(IBAction)stopprogress:(id)sender;
- @end
m 代码
- #import "ViewController.h"
- @interface ViewController ()
- @end
- @implementation ViewController
- @synthesize progressview;
- @synthesize progressviewbar;
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- // Do any additional setup after loading the view, typically from a nib.
- }
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- /* 启动进度条 */
- -(IBAction)startprogress:(id)sender{
- timer = [NSTimer scheduledTimerWithTimeInterval:0.03f target:self selector:@selector(timeChanged:) userInfo:nil repeats:YES];
- /*
- 启动一个定时器,间隔时间为0.03s,间隔0.03s即调用self里边的timechanged方法
- */
- }
- /* 停止进度条,进度都置为零*/
- -(IBAction)stopprogress:(id)sender{
- [timer invalidate];
- // [timer release];
- timer = nil;
- self.progressview.progress=0.0f;
- self.progressviewbar.progress=0.0f;
- }
- /* 进度条进度+0.01*/
- -(IBAction)timeChanged:(id)sender{
- self.progressview.progress +=0.01f;
- self.progressviewbar.progress+=0.01f;
- }
- @end
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。