作用:提示某件事情的進(jìn)度
進(jìn)度條的高度不可變
1.簡(jiǎn)單的屬性方法
- 設(shè)置進(jìn)度條的樣式
@property(nonatomic) UIProgressViewStyle progressViewStyle;
typedef enum {
UIProgressViewStyleDefault, // normal progress bar
UIProgressViewStyleBar // for use in a toolbar
} UIProgressViewStyle;
- 設(shè)置進(jìn)度條當(dāng)前進(jìn)度馏锡,進(jìn)度范圍0~1
@property(nonatomic) float progress;
- 設(shè)置進(jìn)度條的背景顏色
@property(nonatomic,copy) UIColor *backgroundColor;
- 設(shè)置進(jìn)度條已完成進(jìn)度的顏色
@property(nonatomic, strong) UIColor* progressTintColor ;
- 設(shè)置進(jìn)度條的風(fēng)格顏色
@property(nonatomic, strong) UIColor* trackTintColor;
- 設(shè)置進(jìn)度值症歇,并決定是否能夠使用動(dòng)畫
- (void)setProgress:(float)progress animated:(BOOL)animated;
2.代碼例子
創(chuàng)建了一個(gè)進(jìn)度條袁翁,其已完成進(jìn)度顏色是橘黃色藐不,并添加了一個(gè)簡(jiǎn)單的動(dòng)畫减俏,讓其可以動(dòng)起來檀蹋。
//創(chuàng)建
UIProgressView *progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(50, 100, 250, 50)];
//背景顏色
progressView.backgroundColor = [UIColor grayColor];
//樣式
progressView.progressViewStyle = UIProgressViewStyleDefault;
//已完成進(jìn)度顏色
progressView.progressTintColor = [UIColor orangeColor];
//現(xiàn)在的進(jìn)度
//_progressView.progress = 0.5;
//動(dòng)畫
[UIView animateWithDuration:5 animations:^{
[progressView setProgress:0.8 animated:YES];
} completion:^(BOOL finished){
//NULL
}];
//添加
[self.view addSubview:progressView];
運(yùn)行結(jié)果