UIProgressView的详细使用


UIProgressView顾名思义用来显示进度的,如音乐,视频的播放进度,和文件的上传下载进度等。

下面以一个简单的实例来介绍UIprogressView的使用。

 

@interface ActivityViewController : UIViewController

{

    UIProgressView *proView;  

    double proValue;

    NSTimer *timer;

}

 

@property(nonatomicretain)  UIProgressView *proView;

-(IBAction)btnStartClick;

 

 

@implementation ActivityViewController

@synthesize proView;

 

#pragma mark - View lifecycle

-(IBAction)btnStartClick

{

    proValue=0;

     timer = [NSTimerscheduledTimerWithTimeInterval:1target:selfselector:@selector(changeProgress) userInfo:nilrepeats:YES]; //利用计时器,每隔1秒调用一次(changeProgress)

}

-(void)changeProgress

{

    proValue += 1.0//改变proValue的值

    if(proValue > 5)

    {

        //停用计时器

        [timer invalidate];        

    }

    else

    {

        [proViewsetProgress:(proValue / 5)];//重置进度条

    }

}

 

- (void)viewDidLoad

{

    proView = [[UIProgressViewallocinitWithFrame:CGRectMake(10010015020)];

    [proViewsetProgressViewStyle:UIProgressViewStyleDefault]; //设置进度条类型

    [self.viewaddSubview:proView];

    

    [superviewDidLoad];

}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM