一、概述
二、属性
- (instancetype)initWithFrame:(CGRect)frame;
2. 设置 UIProgressView 对象的风格
- (instancetype)initWithProgressViewStyle:(UIProgressViewStyle)style;
typedef NS_ENUM(NSInteger, UIProgressViewStyle) {
UIProgressViewStyleDefault, // 普通样式
UIProgressViewStyleBar // 工具栏样式
};
@property(nonatomic) UIProgressViewStyle progressViewStyle;
4. 设置进度条的当前值;默认为 0,并且范围在 0 ~ 1 之间
@property(nonatomic) float progress;
5. 设置已经走过进度条的颜色
@property(nonatomic, strong, nullable) UIColor* progressTintColor;
6. 设置还未走过进度条的颜色
@property(nonatomic, strong, nullable) UIColor* trackTintColor;
7. 设置已经走过进度条的图片
@property(nonatomic, strong, nullable) UIImage* progressImage;
8. 设置还未走过进度条的图片
@property(nonatomic, strong, nullable) UIImage* trackImage;
9. 设置进度条的当前置,并设置动画效果
- (void)setProgress:(float)progress animated:(BOOL)animated;
三、其他
_progressView.progress = _slider.value;
2)UISlider 对象的 minimumValue 和 maximumValue 不在 0 ~ 1 之间时(和 UIProgressView 的范围不一致),此时需要将 UISlider 的值做一个百分比的转换
_progressView.progress = (_slider.value - _slider.minimumValue) / (_slider.maximumValue - _slider.minimumValue);