测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布最新发布 | 2017 年 9 月 |
SwiftSwift 版本 | 4.0 |
SPM支持 SPM | ✗ |
由 Hironobu Kimura 维护。
#EMTLoadingIndicator
在 watchOS 3+ 显示加载指示器
只需将类和资源文件添加到您的项目中,或者使用 CocoaPods。
use_frameworks!
target :'SomeWatchKitApp Extension', :exclusive => true do
platform :watchos, '4.0'
pod 'EMTLoadingIndicator', '~> 4.0.0'
end
private var indicator: EMTLoadingIndicator?
override func willActivate() {
indicator = EMTLoadingIndicator(interfaceController: self, interfaceImage: image!,
width: 40, height: 40, style: .line)
宽度和高度是传递给第二个参数的 WKInterfaceImage 的大小。指示器图像将以此大小创建。
样式参数决定了等待(循环)指示器的视觉样式 - 点或线。
indicator = EMTLoadingIndicator(interfaceController: self, interfaceImage: image!,
width: 40, height: 40, style: .dot)
// prepareImageForWait will be called automatically in the showWait method at the first time.
// It takes a bit of time. You can call it manually if necessary.
indicator?.prepareImagesForWait()
// show
indicator?.showWait()
// hide
indicator?.hide()
*点指示器的图像是 80px x 80px 的静态资源文件。
这些 PNG 文件是用 Flash CC (waitIndicatorGraphic.fla) 创建的。
indicator = EMTLoadingIndicator(interfaceController: self, interfaceImage: image!,
width: 40, height: 40, style: .line)
indicator?.showWait()
indicator?.hide()
indicator?.prepareImagesForProgress()
// You can set start percentage other than 0.
indicator?.showProgress(startPercentage: 0)
// Update progress percentage with animation
indicator?.updateProgress(percentage: 75)
indicator?.hide()
您可以在一些加载错误情况下显示静态重新加载图标。
indicator?.showReload()
如果您想更改样式,您需要在使用 prepare/show 方法之前设置属性。
// defaults
EMTLoadingIndicator.circleLineColor = UIColor(white: 1, alpha: 0.8)
EMTLoadingIndicator.circleLineWidth = 1
EMTLoadingIndicator.progressLineColorOuter = UIColor(white: 1, alpha: 0.28)
EMTLoadingIndicator.progressLineColorInner = UIColor(white: 1, alpha: 0.70)
EMTLoadingIndicator.progressLineWidthOuter = 1
EMTLoadingIndicator.progressLineWidthInner = 2
EMTLoadingIndicator.reloadColor = UIColor.white
EMTLoadingIndicator.reloadLineWidth = 4
EMTLoadingIndicator.reloadArrowRatio = 3
所有创建的图像都存储在静态属性中,并为所有实例使用。
如果您想清除它们,请使用以下方法。
indicator?.clearWaitImage()
indicator?.clearReloadImage()
indicator?.clearProgressImage()
EMTLoadingIndicator 可在 MIT 许可证下使用。有关更多信息,请参阅 LICENSE 文件。