UIProgressView,也就是进度条,我们经常会在下载的时候看到这个控件,下面就简单介绍UIProgressView的使用方法。
@property (nonatomic,strong) UIProgressView *progress;
-(UIProgressView *)progress {
if (!_progress) {
//进度条高度不可修改
_progress = [[UIProgressView alloc] initWithFrame:CGRectMake(100, 100, 200, 40)];
//设置进度条的颜色
_progress.progressTintColor = [UIColor blueColor];
//设置进度条的当前值,范围:0~1;
_progress.progress = 0.5;
/*
typedef NS_ENUM(NSInteger, UIProgressViewStyle) {
UIProgressViewStyleDefault, // normal progress bar
UIProgressViewStyleBar __TVOS_PROHIBITED, // for use in a toolbar
};
*/
_progress.progressViewStyle = UIProgressViewStyleDefault;
}
return _progress;
}
- (void)viewDidLoad {
[super viewDidLoad];
[self.view addSubview:self.progress];
}
我们可以在需要改变进度的地方修改他的.progress值就可以了