進度條控件:UIProcessView:UIView
@property(nonatomic) UIProgressViewStyle progressViewStyle; //風格類型
@property(nonatomic) float progress; //當前進度
@property(nonatomic, retain) UIColor* progressTintColor; //進度條進度的高亮顏色
@property(nonatomic, retain) UIColor* trackTintColor; //進度條軌道的高亮顏色
@property(nonatomic, retain) UIImage* progressImage; //進度條進度的圖像
@property(nonatomic, retain) UIImage* trackImage; //進度條軌道的圖像
風格:
typedef NS_ENUM(NSInteger, UIProgressViewStyle) {
UIProgressViewStyleDefault, //默認的風格,一種灰白色的風格 (有進度顯示的部分默認為藍色)
UIProgressViewStyleBar, //沒有進度顯示時是無色的風格 (有進度顯示的部分默認為藍色)
};
方法:
※初始化進度條實例
- (instancetype)initWithProgressViewStyle:(UIProgressViewStyle)style;
※設置進度條並且帶有動畫效果
- (void)setProgress:(float)progress animated:(BOOL)animated
舉例如下:
//創建進度條實例
//創建進度條實例 UIProgressView *processView = [[UIProgressView alloc]initWithProgressViewStyle:UIProgressViewStyleDefault];
//設置進度條的frame
//設置它的frame processView.frame = CGRectMake(60, 80,250, 40);
//將控件添加到視圖中
//添加該控件到視圖View中 [self.view addSubview:processView];
此時的進度條結果為:
//設置進度
//設置進度 processView.progress = 0.5;
此時的進度條結果為:
//設置軌道的顏色
//設置它的軌道顏色 processView.trackTintColor = [UIColor redColor];
此時的進度條結果為:
//設置進度條進度的顏色
//設置進度的顏色 processView.progressTintColor = [UIColor greenColor];
此時的進度條結果為:
設置進度條進度和動畫效果
//設置進度條進度的動畫 [processView setProgress:0.8 animated:YES];
演示結果如下:
------>