kentya6 / KYCircularProgress

Flexible progress bar written in Swift.
MIT License
1.15k stars 115 forks source link

Full Full the Circle #13

Closed rauljuarez closed 8 years ago

rauljuarez commented 8 years ago

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?

kentya6 commented 8 years ago

Hi, @rauljuarez. Sorry for the extremely late reply. :(

Yes, KYCircularProgress can draw a full circle. And can use another color when progress completed. I attached a sample code below.

let center = CGPoint(x: 100.0, y: 100.0)
let radius = 30.0
circularProgress.path = UIBezierPath(arcCenter: center, radius: CGFloat(radius), startAngle: CGFloat(0.0), endAngle: CGFloat(M_PI * 2.0), clockwise: true)
circularProgress.lineWidth = radius * 2.0
circularProgress.progressChangedClosure {
    (progress: Double, circularView: KYCircularProgress) in
    if progress == 1.0 {
        self.circularProgress.colors = [UIColor(rgba: 0x6ED2E6FF)]
    }
}

To get a full circle, circularProgress's lineWidth is two times of radius, and handle progressChangedClosure to detect completion of the progress. You can get expectation result like this.