PKLoader
一个基于 Swift 的辅助类,将为您提供应用程序的加载器,在视图或窗口上。
要求
- iOS 10.0+
- Xcode 9.4
安装
对于手动安装,请将源文件夹拖动到您的项目中。
或者使用 CocoaPod,将此行添加到您的 Podfile
pod 'PKLoader'
使用方法
开始加载
- 只需调用
startAnimating()
方法,并传入PKLoader
的shared
实例即可。
示例
//If you want to show the loader on window/full screen, Use:
PKLoader.shared.startAnimating()
//If you want to convert any UIView, UIButton, UILabel etc. in to loader, Use:
PKLoader.shared.startAnimating(onView: <instance_of_your_view>)
停止加载
- 只需调用
stopAnimating()
方法,使用PKLoader
的shared
实例。
示例
PKLoader.shared.stopAnimating()
更改动画的配置
要更改加载器的默认配置,只需更改PKLoaderSettings
的值,例如
重要属性
indicatorType
用于决定加载器的动画类型。默认:PKLoader.IndicatorType.ballRotateChase
仅在全屏加载器情况下有用的属性
-
backgroundSize
用于设置背景视图的大小。默认:CGSize(width: 100.0, height: 100.0)
-
backgroundColor
用于设置背景视图的背景颜色。默认:UIColor.white
-
cornerRadius
用于设置背景视图的圆角。默认:10.0
-
indicatorSize
用于设置指示器动画的默认大小。默认:CGSize(width: 20.0, height: 20.0)
-
indicatorColor
用于设置指示器动画的颜色。默认:UIColor.gray
在两种情况下都适用的属性
-
indicatorPadding
用于设置指示器动画的填充。默认:UIEdgeInsets(top: 5.0, left: 5.0, bottom: 5.0, right: 5.0)
-
shouldMakeRound
决定了是否将传递的视图做成圆形。默认:true
许可证
PKLoader 在 MIT 许可协议下发布。