UIProgressView 进度条(实用)

来源:互联网 发布:js 深度复制对象 编辑:程序博客网 时间:2024/06/06 04:34

.h 

   UIProgressView *progress;

    NSTimer *progressTimer;

    double proValue;


.m

     progress = [[UIProgressView alloc] initWithFrame:CGRectMake(30, 240, 255, 30)];

    [loadingImage addSubview:progress];

    proValue=0;

    progressTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:selfselector:@selector(changeProgress) userInfo:nil repeats:YES];


 

-(void)changeProgress

{

   proValue += 0.1; //proValue    

    if(proValue > 5)

    {

        //停用计时器

        [progressTimer  invalidate];

    }

    else

    {

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

    }

}

0 0
原创粉丝点击