iOS UIKit框架学习—UIProgressView

您可以使用 UIProgressView 类来描述任务的进度,随着时间的推移。进度栏示例是在当它下载邮件时应用程序的底部所示。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
@class UIImageView, CAGradientLayer;
// 进度条风格
typedef NS_ENUM(NSInteger, UIProgressViewStyle) {
UIProgressViewStyleDefault, // 默认
UIProgressViewStyleBar __TVOS_PROHIBITED, // 用于工具栏
};
NS_CLASS_AVAILABLE_IOS(2_0) @interface UIProgressView : UIView <NSCoding>
// 初始化并设置坐标和大小
- (instancetype)initWithFrame:(CGRect)frame NS_DESIGNATED_INITIALIZER;
// 初始化并设置nib
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER;
// 初始化并设置进度条风格
- (instancetype)initWithProgressViewStyle:(UIProgressViewStyle)style;
// 进度条的风格属性
@property(nonatomic) UIProgressViewStyle progressViewStyle;
// 进度值 0.0-1.0
@property(nonatomic) float progress;
// 填充进度条的显示颜色
@property(nonatomic, strong, nullable) UIColor* progressTintColor NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
// 进度条不填充的部分的显示颜色
@property(nonatomic, strong, nullable) UIColor* trackTintColor NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
// 填充进度条的显示图片
@property(nonatomic, strong, nullable) UIImage* progressImage NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
// 进度条不填充的部分的显示图片
@property(nonatomic, strong, nullable) UIImage* trackImage NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
// 设置进度
- (void)setProgress:(float)progress animated:(BOOL)animated NS_AVAILABLE_IOS(5_0);
// 用于更新进度视图的进展对象
@property(nonatomic, strong, nullable) NSProgress *observedProgress NS_AVAILABLE_IOS(9_0);
@end