iOS笔记UI--UIProgressView(进度条)

声明:此为本人学习笔记,若有纰漏错误之处的可留言共同探讨

/*

注意点:

 进度条的progress范围是 0.0 - 1.0  

*/

View部分

#import "MyProgressView.h"

@implementation MyProgressView

+(MyProgressView *)initWithFrame:(CGRect)frame TrackTintColor:(UIColor *)trackTintColor ProgressTintColor:(UIColor *)progressTintColor {
    MyProgressView *myProgressView = [[MyProgressView alloc]init];
    myProgressView.frame = frame;
   
    //进度条还没加载完的颜色
    myProgressView.trackTintColor = trackTintColor;
    
    //进度条已经加载完的颜色
    myProgressView.progressTintColor = progressTintColor;
    return myProgressView ;
}
@end

VC部分

#import "ViewController.h"
#import "MyProgressView.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadingUI];
}

#pragma mark - 更新UI
-(void)loadingUI {
    MyProgressView *progressView =[MyProgressView initWithFrame:CGRectMake(100, 100, 100, 100) TrackTintColor:[UIColor blueColor] ProgressTintColor:[UIColor redColor]];
    [self.view addSubview:progressView];
    
    // 进度条起始位置
    progressView.progress = 0.3;
    progressView.tag = 93;
    
    // 定时器
    //    [NSTimer timerWithTimeInterval:1 target:self selector:@selector(progressAdd:) userInfo:nil repeats:nil];
    [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(progressAdd) userInfo:nil repeats:YES];
    
}

#pragma mark - 进度条
-(void)progressAdd {
    UIProgressView *progressView = (UIProgressView *)[self.view viewWithTag:93];
    progressView.progress += 0.01;
    if (1 == progressView.progress ) {
        progressView.progress = 0;
    }
}


附上完整Demo:http://download.csdn.net/detail/csdn_hhg/9229643


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值