一个提供多个加载动画的 UIView。
要运行示例项目,请在 repo 中克隆,并首先从 Example 目录运行 pod install
。
要将 BALoadingView
添加到您的应用程序中,请添加以下行:
BALoadingView *view = [[BALoadingView alloc] initWithFrame:self.view.frame];
[self.loadingView initialize];
[self.loadingView startAnimation:BACircleAnimationFullCircle];
//OR [self.loadingView startAnimation:BACircleAnimationSemiCircle];
这将默认创建以下动画/按钮
传递 BACircleAnimationSemiCircle
枚举将生成
stopAnimation
从视图中移除动画。
下面列出了您可以控制的几个属性的示例。
initialize
设置默认值,应在设置任何属性之前调用。
如果您想使加载动画持续更久/更短,您可以编辑 duration
属性
BALoadingView *loadingView = [[BALoadingView alloc] initWithFrame:self.view.frame];
[self.loadingView initialize];
self.loadingView.duration = 20.0f;
self.loadingView.segmentColor = [UIColor whiteColor];
[self.loadingView startAnimation:BACircleAnimationFullCircle];
这将创建以下视图
编辑 clockwise
布尔属性可以改变整个圆动画的方向
BALoadingView *loadingView = [[BALoadingView alloc] initWithFrame:self.view.frame];
[self.loadingView initialize];
self.loadingView.clockwise = YES;
self.loadingView.segmentColor = [UIColor whiteColor];
[self.loadingView startAnimation:BACircleAnimationFullCircle];
这将创建以下视图
segmentColor
属性控制段的颜色,可以像上面示例中那样使用
lineCap
属性控制半圆动画的端点。下面的示例是圆形端点选项
[self.loadingView initialize];
self.loadingView.lineCap = kCALineCapRound;
self.loadingView.clockwise = true;
self.loadingView.segmentColor = [UIColor whiteColor];
[self.loadingView startAnimation:BACircleAnimationFullCircle];
动画看起来像这样
Bryan Antigua, [email protected] - bryanantigua.com
BALoadingView遵循MIT许可协议。更多信息请查看LICENSE文件。