首页 > 代码库 > iOS progressview的简单使用
iOS progressview的简单使用
head 代码。。
Java代码
- #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 代码
Java代码
- #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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。