iOS-视图-UIProgressView 进度条

//在.h 文件中声明 UIProgressView* pv;

//进度条 宽度不变
    pv = [[UIProgressView alloc] initWithFrame:CGRectMake(50, 50, 220, 0)];
    //设置类型
    //[pv setProgressViewStyle:UIProgressViewStyleBar];
    //设置颜色
    [pv setTrackTintColor:[UIColor blueColor]];
    [pv setProgressTintColor:[UIColor redColor]];
    //设置图片
    //[pv setTrackImage:];
    //[pv setProgressImage:];
    [self.view addSubview:pv];
    [pv release];
    
    //开启一个定时器
    [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(refresh) userInfo:nil repeats:YES];
    

    ///事件控制 进度条
    - (void)refresh{
    if (pv.progress <= 1.0) {
//        pv.progress += 0.01;
        [pv setProgress:pv.progress + 0.1 animated:NO];
    }
}

你可能感兴趣的:(iOS-视图-UIProgressView 进度条)