VAProgressCircle 是一个自定义的加载动画,用于从 0% 到 100% 加载 iOS 内容。
pod 'VAProgressCircle'
来通过 Cocoapods 安装 VAProgressCircle,或者您可以将 UICountingLabel.h/.m
和 VAProgressCircle.h/.m
手动添加到项目中。您可以通过使用 Interface Builder 中的 UIView 创建一个 VAProgressCircle,继承它到 VAProgressCircle,并将其链接到 UIViewController 的一个属性,或者使用 - (id)initWithFrame:(CGRect)frame
self.progressCircle = [[VAProgressCircle alloc] initWithFrame:CGRectMake(50, 60, 250, 250)];
[self.view addSubview:self.circleChart];
设置您的 VAProgressCircle 的基本颜色。
[self.progressCircle setColor:[UIColor greenColor]];
//Or you can specify a highlight color with your base color
[self.progressCircle setColor:[UIColor greenColor] withHighlightColor:VADefaultGreen];
VAProgressCircle 当达到 100% 时可以转换颜色。这可以通过设置您的 transitionType
来启用。
self.progressCircle.transitionType = VAProgressCircleColorTransitionTypeGradual;
设置您的 VAProgressCircle 的转换颜色。
[self.progressCircle setTransitionColor:[UIColor blueColor]];
//Or you can specify a highlight color with your transition color
[self.progressCircle setColor:[UIColor blueColor] withHighlightTransitionColor:VADefaultBlue];
使用进度块来添加在进度块动画完成后执行的功能
self.circleChart.progressBlock = ^(int progress, BOOL isAnimationCompleteForProgress){
//Add custom block functionality here
};
如果您需要代理模式,不要实现块并设置您的代理,它们将被调用
- (void)viewDidLoad
{
self.progressCircle.delegate = self;
}
#pragma mark - VAProgressCircleDelegate
- (void)progressCircle:(VAProgressCircle *)circle willAnimateToProgress:(int)progress
{
//Add custom delegate functionality here
}
- (void)progressCircle:(VAProgressCircle *)circle didAnimateToProgress:(int)progress
{
//Add custom delegate functionality here
}
切换 VAProgressCircle 的动画功能。
@property BOOL shouldShowAccentLine;
@property BOOL shouldShowFinishedAccentCircle;
@property BOOL shouldHighlightProgress;
@property BOOL shouldNumberLabelTransition;
设置您的 VAProgressCircle 的旋转方向。
self.progressCircle.rotationDirection = VAProgressCircleRotationDirectionClockwise;
VAProgressCircle 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。