AMProgressBar 0.1.0

AMProgressBar 0.1.0

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

Abdul Moiz 维护。



  • 作者
  • Abdul Moiz

AMProgressBar

用 Swift 编写的优雅的 iOS 进度条。

特点

  • 最新版:Swift 3
  • 超级易于使用且轻量级
  • IBInspectable 属性可以从 Interface Builder 进行自定义
  • 全局配置文件以应用跨应用相同的样式。

使用方式

import AMProgressBar

let progressBar = AMProgressBar()
progressBar.progressValue = 1

self.view.addSubview(progressBar)

全局配置

使用这些简单的代码行设置所有进度条的全局样式。如果从界面构建器设置有不同值,则会覆盖。

AMProgressBar.config.barColor = .blue
AMProgressBar.config.barCornerRadius = 10
AMProgressBar.config.barMode = .determined // .undetermined

AMProgressBar.config.borderColor = .white
AMProgressBar.config.borderWidth = 2

AMProgressBar.config.cornerRadius = 10

AMProgressBar.config.hideStripes = false

AMProgressBar.config.stripesColor = .red
AMProgressBar.config.stripesDelta = 80
AMProgressBar.config.stripesMotion = .right // .none or .left
AMProgressBar.config.stripesOrientation = .diagonalRight // .diagonalLeft or .vertical
AMProgressBar.config.stripesWidth = 30

AMProgressBar.config.textColor = .black
AMProgressBar.config.textFont = UIFont.systemFont(ofSize: 12)
AMProgressBar.config.textPosition = .onBar // AMProgressBarTextPosition

批量自定义

当使用 AMProgressBar 时,建议使用 customize(block:) 方法进行自定义。原因是 AMProgressBar 对您设置的每个属性都会做出反应。因此,如果您设置了 3 个属性,进度条将刷新 3 次。

当使用 customize(block:) 时,您可以分组进度条上所有自定义,这样 AMProgressBar 只会刷新自身一次。

示例

progressBar.customize { bar in
    bar.cornerRadius = 10
    bar.borderColor = UIColor.gray
    bar.borderWidth = 4

    bar.barCornerRadius = 10
    bar.barColor = UIColor.blue
    bar.barMode = AMProgressBarMode.determined.rawValue

    bar.hideStripes = false
    bar.stripesColor = UIColor.white
    bar.stripesWidth = 10
    bar.stripesDelta = 10
    bar.stripesMotion = AMProgressBarStripesMotion.right.rawValue
    bar.stripesOrientation = AMProgressBarStripesOrientation.diagonalRight.rawValue

    bar.textColor = UIColor.black
    bar.textFont = UIFont.systemFont(ofSize: 12)
    bar.textPosition = AMProgressBarTextPosition.middle.rawValue
}

示例

要运行示例项目,请克隆仓库,然后先从示例目录运行 pod install

要求

  • Swift 3
  • iOS 8.0+

灵感来源

许可

AMProgressBar 适用于 MIT 许可。有关更多信息,请参阅 LICENSE 文件。