KRIndicatorController
KRIndicatorController 是用于显示后台活动UI的控制器。
安装
KRIndicatorController
通过 CocoaPods 提供。要安装它,请简单地将以下行添加到 Podfile 中
pod 'KRIndicatorController', :git=>'https://github.com/funct7/KRIndicatorController.git', :branch=>'develop'
然后,运行以下命令:
$ pod install
用法
基本
使用默认的指示器视图
import KRIndicatorController
class ViewController: UIViewController {
private let ic = IndicatorController()
private func beginOperation() {
ic.increment()
// Begin some operation
}
private func endOperation() {
// End some operation
ic.decrement()
}
}
自定义指示器视图
使用自定义指示器视图
import KRIndicatorController
class CustomIndicator: IndicatorItem {
var view: UIView
init() {
// Initialize
}
func animateShow() {
// Custom animation
}
func animateHide() {
// Custom animation
}
}
class ViewController: UIViewController {
private let ic = IndicatorController()
private func setCustomIndicatorView() {
ic.indicatorItem = CustomIndicator()
}
}
自定义延迟
设置自定义延迟值
import KRIndicatorController
class ViewController: UIViewController {
private let ic = IndicatorController()
private func setCustomDelay() {
ic.delay = 0.3 // 300 ms delay
}
}
阻止/允许用户交互
在指示器显示期间阻止用户交互
import KRIndicatorController
class ViewController: UIViewController {
private let ic = IndicatorController()
override func viewDidLoad() {
super.viewDidLoad()
ic.isUserInteractionBlocked = true // Default is true
}
}
将`isUserInteractionBlocked`设置为`false`允许用户与底层视图交互。