WatchActivityIndicator
Apple Watch 的 WKInterfaceImage
和 WKInterfaceGroup
扩展,用于快速显示活动指示器。
演示
要求
- watchos 2.0+
- Swift 5.0+
- Xcode 10.2+
安装
Cocoapods
target 'your_watch_extension_target' do
platform :watchos, 2.0
pod 'WatchActiviyIndicator'
end
使用方法
在任意 WKInterfaceImage
或 WKInterfaceGroup
实例上调用 startActivityIndicator
和 stopActivityIndicator
函数以实现默认活动指示器。
// start
imageView?.startActivityIndicator()
group?.startActivityIndicator()
// stop
imageView?.stopActivityIndicator()
group?.stopActivityIndicator()
可以为 startActivityIndicator
设置参数来自定义动画序列和持续时间。
imageView?.startActivityIndicator(
imageNamed: "CustomAnimation",
animationRange: NSMakeRange(0, frameCount),
duration: customAnimationDuration)
适用于任何图像视图或组合。