Skip to content

Commit

Permalink
Update GradientProgressView.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
moliya authored Aug 25, 2021
1 parent 7b24072 commit a25f5e0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Sources/GradientProgressView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

import UIKit

@objc(KFGradientProgressView)
open class GradientProgressView: UIView {

//进度条完成部分的渐变颜色,设置单个为纯色,设置多个为渐变色
@objc
public var progressColors: [UIColor] = [.systemBlue] {
didSet {
if progressColors.count == 0 {
Expand All @@ -25,20 +27,23 @@ open class GradientProgressView: UIView {
}

//进度条完成部分的圆角半径
@objc
public var progressCornerRadius: CGFloat = 0 {
didSet {
maskLayer.cornerRadius = progressCornerRadius
}
}

//进度完成部分的内间距
@objc
public var progressEdgeInsets: UIEdgeInsets = .zero {
didSet {
setNeedsLayout()
}
}

//当前进度
@objc
public var progress: Float {
get {
return privateProgress
Expand All @@ -59,12 +64,15 @@ open class GradientProgressView: UIView {
}()

//动画持续时间
@objc
public var animationDuration: TimeInterval = 0.3

//动画时间函数
@objc
public var timingFunction: CAMediaTimingFunction = CAMediaTimingFunction(name: .default)

//进度更新动画过程中的回调,在这里可以拿到当前进度及进度条的frame
@objc
public var progressUpdating: ((Float, CGRect) -> ())?


Expand Down Expand Up @@ -113,6 +121,7 @@ open class GradientProgressView: UIView {
}

// MARK: - Public
@objc(setProgress:animated:)
public func setProgress(_ progress: Float, animated: Bool) {
let validProgress = min(1.0, max(0.0, progress))
if privateProgress == validProgress {
Expand Down

0 comments on commit a25f5e0

Please sign in to comment.