EMTLoadingIndicator 4.0.0

EMTLoadingIndicator 4.0.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最新发布2017 年 9 月
SwiftSwift 版本4.0
SPM支持 SPM

Hironobu Kimura 维护。



  • Hironobu Kimura

#EMTLoadingIndicator
在 watchOS 3+ 显示加载指示器

安装

只需将类和资源文件添加到您的项目中,或者使用 CocoaPods。

Podfile

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 的大小。指示器图像将以此大小创建。
样式参数决定了等待(循环)指示器的视觉样式 - 点或线。

点指示器

Image

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) 创建的。

线(圆形)指示器

Image

indicator = EMTLoadingIndicator(interfaceController: self, interfaceImage: image!,
    width: 40, height: 40, style: .line)
indicator?.showWait()
indicator?.hide()

进度指示器

Image

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()

重新加载图标

Image

您可以在一些加载错误情况下显示静态重新加载图标。

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()

要求

  • watchOS 3.0+

许可证

EMTLoadingIndicator 可在 MIT 许可证下使用。有关更多信息,请参阅 LICENSE 文件。