Install KDCircularProgress via CocoaPods
masterTo install KDCircularProgress using CocoaPods, add the following line to your Podfile:
pod 'KDCircularProgress'Then, execute the install command in your terminal:
$ pod installrepository·master·Indexed 22 days ago
https://github.com/kaandedeoglu/kdcircularprogressA Swift-based circular progress view component for iOS featuring support for gradients, glows, and animations. It is compatible with Interface Builder via IBInspectable and IBDesignable, and can be installed via CocoaPods, Carthage, or manual integration. The library provides customizable properties for thickness, angles, and glow modes, along with methods for animating progress between specific angles.
To install KDCircularProgress using CocoaPods, add the following line to your Podfile:
pod 'KDCircularProgress'Then, execute the install command in your terminal:
$ pod installKDCircularProgress.swift file directly into your Xcode project.To install KDCircularProgress using Carthage, add the following line to your Cartfile:
github "kaandedeoglu/KDCircularProgress"Then, run the update command:
carthage updateYou can instantiate and configure KDCircularProgress programmatically. It is recommended to use square frames to avoid unexpected results.
Here is a complete setup example:
progress = KDCircularProgress(frame: CGRect(x: 0, y: 0, width: 300, height: 300))
progress.startAngle = -90
progress.progressThickness = 0.2
progress.trackThickness = 0.6
progress.clockwise = true
progress.gradientRotateSpeed = 2
progress.roundedCorners = false
progress.glowMode = .forward
progress.glowAmount = 0.9
progress.set(colors: UIColor.cyan ,UIColor.white, UIColor.magenta, UIColor.white, UIColor.orange)
progress.center = CGPoint(x: view.center.x, y: view.center.y + 25)
view.addSubview(progress)You can initialize the component using the following methods:
init(frame: CGRect): Standard initializer. Note: Use square frames only.init(frame: CGRect, colors: UIColor...): Convenience initializer that sets the gradient colors immediately.Use the following methods to animate the progress view:
animateFromAngle(fromAngle:toAngle:duration:relativeDuration:completion:): Animates from a specific starting angle to a target angle. relativeDuration determines if the duration is for the specific segment or for a full turn.animateToAngle(toAngle:duration:completion:): Animates from the current state to a target angle.pauseAnimation(): Pauses any active animation.isAnimating() -> Bool: Returns true if an animation is currently running.You can update the gradient colors using either of these methods:
set(colors: UIColor...): Variadic method to pass multiple colors.set(colors: [UIColor]): Method to pass an array of colors.The glowMode property (of type KDCircularProgressGlowMode) controls how the glow effect scales with the progress angle:
.forward: Glow increases proportionally to the angle (0 at 0°, full at 360°)..reverse: Glow increases inversely to the angle (full at 0°, 0 at 360°)..constant: The glow intensity remains constant..noGlow: No glow effect is applied.The following properties allow you to customize the appearance of the circular progress view:
| Property | Type | Description |
|---|---|---|
progressColors | [UIColor] | Colors used for the gradient. If only one color is provided, it uses a fill instead. |
angle | Int | The current visual progress (0 to 360). |
startAngle | Int | The starting angle (0 to 360). Values outside this range are automatically modulated. |
clockwise | Bool | Direction of progress. true for clockwise, false for counter-clockwise. |
roundedCorners | Bool | If true, the ends of the progress track are drawn with a half-circle radius. |
gradientRotateSpeed | CGFloat | Number of 2π rotations the gradient performs per full progress cycle. |
glowAmount | CGFloat | Intensity of the glow (0.0 to 1.0). |
glowMode | KDCircularProgressGlowMode | Determines how the glow behaves relative to the angle. |
progressThickness | CGFloat | Thickness of the progress bar (0.0 to 1.0). |
trackThickness | CGFloat | Thickness of the background track (0.0 to 1.0). |
trackColor | UIColor | Color of the background track. |
progressInsideFillColor | UIColor | Color of the center of the circle. |