kentya6 / kycircularprogress Goto Github PK
View Code? Open in Web Editor NEWFlexible progress bar written in Swift.
License: MIT License
Flexible progress bar written in Swift.
License: MIT License
when update to swift4.2
Low fps on scroll
KYCircularProgress inside UITableViewCell
I know this might seem overkill for the size of your project, but it would help a lot to keep up with updates.
When I set colors on the circularProgress view, I get a runtime error. I also get the error when I run the sample project. For example:
//the exception happens when I do this
circularProgress.colors = [0xFFF77A, 0xF3C0AB];
Here is the error:
KYCircularProgress.swift
Line 60. self.gradientLayer.colors = convertedColors
fatal error: array element cannot be bridged to Objective-C
cool demo.have obj-c version?
Hi, thanks for this open source project. Like it so far but cannot get some wanted behavior.
I want to use single circular bar for multiple cases, or dynamically change its current progress.
But, as soon as I start animation there is no way to reset it to another value to start new animation.
For example I tried to start animation from 0.6 to 0 in 600 seconds.
After some user progress, I want to reset animation without waiting it to finish all 10 minutes, for example, to progress 0.8 and animate to 0 in 300 seconds.
But it just starts from previous animation last position and resets timer to 300 even if very small portion left, it divides that portion into.. 300 seconds.
Im trying to set its inital value too, not only duration.
I tried so far
popupProgressCircle.progress = 0.8 // Doesnt work if animation in progress
popupProgressCircle.set(progress: 0.8, duration: 0) // Also doesnt work if animation in progress
popupProgressCircle.set(progress: 0.8, duration: 0.000001) // This just breaks everything, may be because next part is called immediately, and code execution is faster than 0.000001
popupProgressCircle.set(progress: 0, duration: 300) // This works, but because of above part doesnt work, it is just making slower and slower every attempts remaining part
So I want to achieve - either reset/stop animation in order to safely set new progress value, or just set progress value and it is automatically stops all current animations.
On top of that, there is no way to check if any animation is currently ongoing without waiting progress delegate~ But its just minor issue
Using Swift 5.1 and XCode 11.
If I call setProgress(progress:duration)
several times, it appears that animations are not updated smoothly. I suspect is due to the fact that when calling setProgress(progress:duration)
the new animation starts where the previous one ends, even if it is not terminated.
If you confirm my analysis, I can work on a Pull request to correct this.
I have issue setting correct width and height for progress view.
let circularProgressView : KYCircularProgress = {
// this way (without some default frame) it doesnt work at all, even though autolayout sets frame later.
//let circularProgress = KYCircularProgress()
// Random height/width
let circularProgress = KYCircularProgress(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
circularProgress.lineWidth = 3.2
circularProgress.guideLineWidth = 2.8
circularProgress.lineCap = CAShapeLayerLineCap.round.rawValue
circularProgress.translatesAutoresizingMaskIntoConstraints = false
circularProgress.backgroundColor = .white
return circularProgress
}()
For this code, and constrainting circularProgressView
to 5
for top, bottom, trailing and aspectRatio 1 (perfect square):
circularProgressView.topAnchor.constraint(equalTo: graphContainer.topAnchor, constant: 5).isActive = true
circularProgressView.trailingAnchor.constraint(equalTo: graphContainer.trailingAnchor, constant: -5).isActive = true
circularProgressView.bottomAnchor.constraint(equalTo: graphContainer.bottomAnchor, constant: -5).isActive = true
circularProgressView.widthAnchor.constraint(equalTo: circularProgressView.heightAnchor, multiplier: 1).isActive = true
I am getting following result
As you can see, autolayout setting correct frame according to white background color, inner circleViews are resized (from 100, 100
to 41, 41
frame). But inner circles are not perfectly centered, approximately: (left: 5 top: 5, bottom: 8, right: 8), and dont have size I need (same as white circle).
Am I missing something? circularProgressView.setNeedsLayout on parent LayoutSubviews doesnt work.
Swift 5, XCode 11.3.1 (11C504)
Is it possible to convert it to a UISlider ? I'm not really good in Swift so, i don't know if i'm able to do it myself.
Thanks for your control.
Sorry, there is no such place that I could ask about this. so I post it here.
I would like to show various data through this framework, however it keeps being reset.
on my project I used timer.scheduled to get some animation.
there is 2 integers I have set
for example
private var progress: UInt8 = 0
var totalAmount:Int = 28000
var paidAmount:Int = 8000
@IBOutlet private weak var storyboardCircularProgress1: KYCircularProgress!
@IBOutlet private weak var progressLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
configureStoryboardProgress1()
updateProgress()
}
private func configureStoryboardProgress1() {
storyboardCircularProgress1.colors = [.purple, .purple, .purple]
storyboardCircularProgress1.progressChanged {
(progress: Double, circularProgress: KYCircularProgress) in
self.progressLabel.text = String.init(format: "%.0f", progress * 100.0) + "%"
}
storyboardCircularProgress1.
}
@objc private func updateProgress() {
progress = progress &+ 2
let normalizedProgress = Double(progress) / Double(UInt8.max)
storyboardCircularProgress1.progress = normalizedProgress
if progress == 255
{
}
if progress < UInt8(Double(paidAmount) / Double(totalAmount) * 255)
{
self.addTime()
}
}
func addTime()
{
Timer.scheduledTimer(timeInterval: 0.01, target: self, selector: #selector(updateProgress), userInfo: nil, repeats: false)
}
}
the animation showed 30% whiles it's about 29.6% that's great however, when I set
var totalAmount:Int = 28000
var paidAmount:Int = 0
the result will be 1% that's weird and also
var totalAmount:Int = 28000
var paidAmount:Int = 28000
then the result keeps being reset and animation goes forever like your demo.
I really wish that I could use the framework for my project, it's really simple and nice but I'm not capable enough to fix this problem. Hope you could kindly guide me to right path.
Thanks million in advance.
I believe the Swift compiler (I'm on Xcode 6.1) is getting confused because you have a computed property called progressChangedClosure and a function of the same name.
I had to set the showProgressGuide after initialization for it to work, even when I set this value to true in the parameters for the initializer.
Thanks for tool.
KYCircularProgress class doesn't handle correctly changing values startAngle & endAngle.
It happens because of method layoutSubviews in KYCircularShapeView only calls one time (KYCircularShapeView wasn't added as subview).
I think the KYCircularShapeView should update path every time when we update angle values
I've run into an issue in xcode 8 where applying constraints or using autoresizing on the KYCircularProgress view causes the progress bar to display in unexpected ways.
Positioning constraints appear to affect the guide line, causing it to no longer display (or be moved outside of the view). Any constraints relating to the size of the view (width, height etc.) cause the progress line to be massively enlarged.
The views frame appears to react correctly to the constraints, it is just the graphic that is affected. Setting the constraints programmatically has the same effect.
Setting the constraints and saving the storyboard for xcode 7 fixes the issues. This works fine as a workaround
No Constraints
Positioning Constraints
Size Constraints
I'm using autolayout and I've set constraints to the KYCircularProgress view.
But after autolayout resized it's frame - KYCircularProgress's layer doesn't redraw according to the new frame.
I wanted to implement a gauge with that framework.
I came across an issue where the circle was offset to the right.
I colored the frames of the label (which is centred) and the gauge itself. as you can see the circle is offset. In my implementation I did nothing else then setting the lineWidths and colours
Hi, is possible to use this to get a full circle and filled? i mean draw a white circle and animate the completion of the progress of it using another color?
Could you please upgrade this project to Swift 4?
Hi ,
I just want the animation start from the top of the circle.
So I set the startAngle as -Double.pi / 2 , but it still start from 0 .
Is there anything I missed?
Here is my code :
@IBAction func runAction(_ sender: Any) {
productACircularProgress.colors = [.purple, UIColor(rgba: 0xFFF77 A55), .orange]
productACircularProgress.startAngle = -Double.pi / 2
productACircularProgress.set(progress: 0.618, duration: 0.75)
}
Thanks in advance!
hello,
i want to close KYCircularProgress.
how can i do.
use removeFromSuperview() can't all remove
just want to ask, is this library support progress bar that its color can be set in start , center and end. Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.