有没有办法让循环进度条超过100%?
Is there any way to make circular progress bar beyond 100%?
起初我想使用饼图,但后来我点击了循环进度,现在它需要超过 100%。
是否有任何方法可以为 swift 修改任何现有的循环进度条 SDK 或实现此行为的任何替代方法?
使用 Donut Graph 之类的怎么样?
编辑:是gif,附上。不知道为什么它不能像 gif 那样播放! (点击查看即可)
为此使用 KDCircularProgress。
import KDCircularProgress // I'm using (1.5.4)
@IBOutlet weak var progress: UIView!
private var progressBar: KDCircularProgress?
private var totalPer = 120.0
private func setupProgressUI() {
let progress = KDCircularProgress(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
self.progress.addSubview(progress)
progress.startAngle = -90
progress.progressThickness = 0.8
progress.trackThickness = 0.8
progress.trackColor = .darkGray
progress.roundedCorners = true
progress.set(colors: UIColor.orange)
progress.translatesAutoresizingMaskIntoConstraints = false
progress.leadingAnchor.constraint(equalTo: self.progress.leadingAnchor).isActive = true
progress.trailingAnchor.constraint(equalTo: self.progress.trailingAnchor).isActive = true
progress.topAnchor.constraint(equalTo: self.progress.topAnchor).isActive = true
progress.bottomAnchor.constraint(equalTo: self.progress.bottomAnchor).isActive = true
self.progressBar = progress
}
private func setupProgressData() {
self.progressBar?.trackColor = .darkGray
self.setProgress(percentage: self.totalPer)
}
private func setProgress(percentage: Double) {
var percentage = percentage
if percentage > 100 {
percentage -= 100
self.progressBar?.animate(fromAngle: 0, toAngle: 360, duration: 2) { isComplete in
if isComplete && percentage > 0 {
self.progressBar?.trackColor = UIColor.orange.withAlphaComponent(0.75)
self.setProgress(percentage: percentage)
}
}
} else {
self.progressBar?.animate(fromAngle: 0, toAngle: percentage * 3.6, duration: 2, completion: nil)
}
}
起初我想使用饼图,但后来我点击了循环进度,现在它需要超过 100%。
是否有任何方法可以为 swift 修改任何现有的循环进度条 SDK 或实现此行为的任何替代方法?
使用 Donut Graph 之类的怎么样?
编辑:是gif,附上。不知道为什么它不能像 gif 那样播放! (点击查看即可)
为此使用 KDCircularProgress。
import KDCircularProgress // I'm using (1.5.4)
@IBOutlet weak var progress: UIView!
private var progressBar: KDCircularProgress?
private var totalPer = 120.0
private func setupProgressUI() {
let progress = KDCircularProgress(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
self.progress.addSubview(progress)
progress.startAngle = -90
progress.progressThickness = 0.8
progress.trackThickness = 0.8
progress.trackColor = .darkGray
progress.roundedCorners = true
progress.set(colors: UIColor.orange)
progress.translatesAutoresizingMaskIntoConstraints = false
progress.leadingAnchor.constraint(equalTo: self.progress.leadingAnchor).isActive = true
progress.trailingAnchor.constraint(equalTo: self.progress.trailingAnchor).isActive = true
progress.topAnchor.constraint(equalTo: self.progress.topAnchor).isActive = true
progress.bottomAnchor.constraint(equalTo: self.progress.bottomAnchor).isActive = true
self.progressBar = progress
}
private func setupProgressData() {
self.progressBar?.trackColor = .darkGray
self.setProgress(percentage: self.totalPer)
}
private func setProgress(percentage: Double) {
var percentage = percentage
if percentage > 100 {
percentage -= 100
self.progressBar?.animate(fromAngle: 0, toAngle: 360, duration: 2) { isComplete in
if isComplete && percentage > 0 {
self.progressBar?.trackColor = UIColor.orange.withAlphaComponent(0.75)
self.setProgress(percentage: percentage)
}
}
} else {
self.progressBar?.animate(fromAngle: 0, toAngle: percentage * 3.6, duration: 2, completion: nil)
}
}