您可以使用 UIProgressView 类来描述任务的进度,随着时间的推移。进度栏示例是在当它下载邮件时应用程序的底部所示。
@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
网友评论