A circular progress view with gradients written in Swift

Overview

KDCircularProgress

Version License Platform

KDCircularProgress is a circular progress view written in Swift. It makes it possible to have gradients in the progress view, along with glows and animations.

KDCircularProgress also has IBInspectable and IBDesignable support, so you can configure and preview inside the Interface Builder.

Here's an example

Youtube Link

Screenshot

Screenshot Screenshot Screenshot Screenshot Screenshot Screenshot Screenshot

Requirements

KDCircularProgress requires iOS 8+, although iOS 8 support hasn't been tested in a while.

Installation

  • It's on CocoaPods under the name (you guessed it!) KDCircularProgress
  • Just drag KDCircularProgress.swift into your project. Carthage support is on To-do list.

CocoaPods

KDCircularProgress is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'KDCircularProgress'

then run

$ pod install

Carthage

Add the line github "kaandedeoglu/KDCircularProgress" to your Cartfile and then run the command:

carthage update

Manually

Just drag KDCircularProgress.swift into your project.

Sample Code

Below you can see code that creates and sets up a KCircularProgress instance. Which gives you a configuration that looks similar to the progress in the example images.

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)

Properties

progressColors: [UIColor]

The colors used to generate the gradient of the progress. You can also set this using the variadic setColors(UIColor...) method. A gradient is used only if there is more than one color. A fill is used otherwise. The default is a white fill.

angle: Int

The angle of the progress. Between 0 and 360 (inclusive). Simply change its value in order to change the visual progress of the component. Default is 0.

startAngle: Int

The angle at which the progress will begin. Between 0 and 360 (inclusive), however you can pass any negative or positive values and the component will mod them automatically to the required range. Default is 0.

clockwise: Bool

Clockwise if true, Counter-clockwise if false. Default is true.

roundedCorners: Bool

When true, the ends of the progress track will be drawn with a half circle radius. Default is false.

gradientRotateSpeed: CGFloat

Describes how many times the underlying gradient will perform a 2π rotation for each full cycle of the progress. Integer values recommended. Default is 0.

glowAmount: CGFloat

The intensity of the glow. Between 0 and 1.0. Default is 1.0.

glowMode: KDCircularProgressGlowMode

  • .forward - The glow increases proportionaly to the angle. No glow at 0 degrees and full glow at 360 degrees.

  • .reverse - The glow increases inversely proportional to the angle. Full glow at 0 degrees and no glow at 360 degrees.

  • .constant - Constant glow.

  • .noGlow - No glow

The default is .forward

progressThickness: CGFloat

The thickness of the progress. Between 0 and 1. Default is 0.4

trackThickness: CGFloat

The thickness of the background track. Between 0 and 1. Default is 0.5

trackColor: UIColor

The color of the background track. Default is UIColor.blackColor().

progressInsideFillColor: UIColor

The color of the center of the circle. Default is UIColor.clearColor().

Methods

override public init(frame: CGRect)

Initialize with a frame. Please only use square frames.

convenience public init(frame:CGRect, colors: UIColor...)

Initialize with a frame and the gradient colors.

public func set(colors: UIColor...)
public func set(colors: [UIColor])

Set the colors for the progress gradient.

public func animateFromAngle(fromAngle: Int, toAngle: Int, duration: NSTimeInterval, relativeDuration: Bool = true, completion: ((Bool) -> Void)?)

Animate the progress from an initial value to a final value, with a completion block that fires after the animation is done. relativeDuration - specify if the duration is for the specific animation or is the duration that would make a full turn.

public func animateToAngle(toAngle: Int, duration: NSTimeInterval, completion: ((Bool) -> Void)?)

Animate the progress from the current state to a target value.

public func pauseAnimation()

Pause the animation, if any.

public func isAnimating() -> Bool

Check if there's an active animation.

Misc

Prefering light colors in the gradients gives better results. As mentioned before, use square frames. Rectangular frames are not tested and might produce unexpected results.

Contact

Drop me an email if you want discuss anything further.

Email

License

The MIT License (MIT)

Copyright (c) 2017 Kaan Dedeoglu

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comments
  • Circle animation immidiatelly finish when you press home button and get back

    Circle animation immidiatelly finish when you press home button and get back

    1. Start animation
    2. Press home button
    3. Quickly get back to the app
    4. Animation should be continuosly displayed but the effect is that the circle is fully drawn and animation has finished

    You can reproduce it on your example project

    opened by yakoobs 14
  • Swift 4 support

    Swift 4 support

    Hi, I've faced a problem since I upgraded my xcode. When I try to build the project, this compile error is raised.

    @IBInspectable public var glowMode: KDCircularProgressGlowMode = .forward {
        didSet {
            progressLayer.glowMode = glowMode
        }
    }
    

    Property cannot be marked @IBInspectable because its type cannot be represented in Objective-C

    opened by Kianoosh76 13
  • update 1.5.3 to CocoaPods

    update 1.5.3 to CocoaPods

    Originally posted by @ryanfelton in https://github.com/kaandedeoglu/KDCircularProgress/pull/101#issuecomment-430603040

    @ryanfelton is correct. Currently, the CocoaPod Spec https://cocoapods.org/pods/KDCircularProgress/ points to KDCircularProgress 1.5.2 so trying to compile results in Swift compiler errors now, not just warnings.

    opened by ferrerod 11
  • ObjC -  setColors / progressColors not found

    ObjC - setColors / progressColors not found

    Hi, upgraded version from 1.5.2 to 1.5.4. i have a mix ObjC/Swift project and i'm unable to set the progress colors from my ObjC classes. getting the following error: "Property 'progressColors' not found on object of type 'KDCircularProgress *'" also unable to use set(colors:) or any other function i found to set the progress colors. am i missing anything ? how should i set the progress colors from my objC classes ? Thanks.

    opened by tamir-maoz 10
  • App crashing when calling progress() from async thread

    App crashing when calling progress() from async thread

    My app is crashing when calling progress() and finished from async thread, as the progressLayer.presentationLayer() is nil.

    Is that an issue of KDCircularProgress or am I doing something wrong?

    opened by sneps85 9
  • Many Errors after conversion to Swift3

    Many Errors after conversion to Swift3

    Hello,

    it is stated that master branch is now compatible with Swift 3. I am using Xcode Version 8.0 (8A218a) and testing KDCircularProgress with a test project. After CocoaPods pod install to version KDCircularProgress (1.5.2), and opening the workspace file, Xcode wants to convert to Swift 3. This conversion fails with 66 errors in module KDCircularProgress.swift.

    If it is compatible with Swift 3, what am I doing wrong here? Thanks, Tom

    opened by TomMajor 8
  • Property cannot be marked @IBInspectable because its type cannot be represented in Objective-C

    Property cannot be marked @IBInspectable because its type cannot be represented in Objective-C

    I am using the newest Swift version and the newest xCode version. I get that error at this function:

    @IBInspectable public var glowMode: KDCircularProgressGlowMode = .forward {
        didSet {
            progressLayer.glowMode = glowMode
        }
    }
    

    Have you plannend a upgrade to swift 4?

    opened by Jasperav 7
  • Empty Space surrounding the progress indicator within the UIView

    Empty Space surrounding the progress indicator within the UIView

    Hi, I have noticed that when the KDCircularProgress UIView is implemented there is a lot of empty space within the UIView surrounding the indicator, which takes up a fair amount of screen real-estate(see attached photo). Is there a way to reduce the amount of empty space? kdprogress_example

    opened by RyanHop3 6
  • Does the Swift 3 version work in iOS 8 and 9?

    Does the Swift 3 version work in iOS 8 and 9?

    Or do we need to do something special for apps that support iOS 8.4 and 9? My app uses this library but now crashes in iOS 10. If I update the library is there anything special needed to make sure it continues running on peoples devices that are running iOS 8 and 9?

    opened by AtheistP3ace 6
  • Completion status returning false on complete

    Completion status returning false on complete

    I create a CircularProgress at on button press. I than send off a GET request and if I am animating when I finish with my request I pause and set a new animateFromAngle to complete in 1 second. I appears that doing this is causing the completed to return false in the new animeFromAngle.

    opened by ghost 6
  • Setting start angle or angle cause bad access

    Setting start angle or angle cause bad access

    Since the update, setting start angle or angle would crash and the error is bad access.

    screen shot 2016-04-09 at 21 01 46

    I can't figure out why changing from int to double implementation would cause this error?

    If I use step over, the error occurs right after this line.

    opened by DBL-Lee 6
  • Animating  to scale the progressview

    Animating to scale the progressview

    When we animate the progressview it works fine but when app is minimized and resumed view gets scaled wrongly

    progressView.transform = CGAffineTransform(scaleX: 1.2, y: 1.2);

    opened by ashwath20 0
  • Make the scale identical to the device.

    Make the scale identical to the device.

    Do upgrade from: UIGraphicsBeginImageContextWithOptions(size, false, 0.0) to: UIGraphicsBeginImageContextWithOptions(size, false, UIScreen.main.scale)

    opened by budnik1990 0
  • KDCircularProgress.framework: mach-o, but wrong architecture

    KDCircularProgress.framework: mach-o, but wrong architecture

    xcode Version 12.0.1 macos 10.15.7 swift5

    xib中调用 KDCircularProgress 报错, ViewController.xib: error: IB Designables: Failed to render and update auto layout status for UIView (i5M-Pr-FkT): dlopen(KDCircularProgress.framework, 1): no suitable image found. Did find: KDCircularProgress.framework: mach-o, but wrong architecture

    opened by kou8910 1
  • crash on iOS 9.3.6

    crash on iOS 9.3.6

    while using this framework on devices containing iOS latest 9.3.6 version , there is a crash on the following

    override init() {
    super.init()
    }
    

    of private class KDCircularProgressViewLayer: CALayer

    Xcode: 11.5 MacOS: Catalina Device: iPad 3

    opened by pop-goes-the-Weasel 12
  • Remove assert code?

    Remove assert code?

    Hi useful library!

    Issue

    I use 1.5.4 (via CocoaPods) and sometimes have crash on assert. I don't want this behavior as it works fine without these assertion, so re-installed via Carthage so assert is always disabled in Release build.

    Proposal

    Can we remove these assertions? We might want to ensure these conditions by writing tests or using custom build flags... etc, not affecting in customer(developers) side. Thoughts?

    opened by toshi0383 0
Releases(1.5.2)
Owner
Kaan Dedeoglu
Kaan Dedeoglu
A simple animated progress bar in Swift

DSGradientProgressView Introduction DSGradientProgressView is a simple and customizable animated progress bar written in Swift. Inspired by GradientPr

Dhol Studio 445 Oct 13, 2022
Simple Swift Progress HUD

MKProgress An iOS Simple Swift Progress HUD Requirements iOS 9.0+ Swift 3.0+ Xcode 8.0+ Installation MKProgress is only available via CocoaPods: pod '

Muhammad Kamran 143 Dec 23, 2022
A clean and lightweight progress HUD based on SVProgressHUD, converted to Swift with the help of Swiftify.

IHProgressHUD IHProgressHUD is a clean and easy-to-use HUD meant to display the progress of an ongoing task on iOS and tvOS. IHProgressHUD is based on

Swiftify 202 Dec 22, 2022
UIProgressView replacement with an highly and fully customizable animated progress bar in pure Core Graphics

The YLProgressBar is an UIProgressView replacement with a highly and fully customizable animated progress bar in pure Core Graphics. It has been imple

Yannick Loriot 1.3k Jan 5, 2023
Flexible Stepped Progress Bar for IOS

FlexibleSteppedProgressBar This is a stepped progress bar for IOS. The base code is derived from ABSteppedProgressBar. Most of the design is customisa

Amrata Baghel 549 Jan 6, 2023
📊 A customizable gradient progress bar (UIProgressView).

GradientProgressBar A customizable gradient progress bar (UIProgressView). Inspired by iOS 7 Progress Bar from Codepen. Example To run the example pro

Felix M. 490 Dec 16, 2022
Simple and powerful animated progress bar with dots

Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements iOS 8.0+ Swift 3.0+ Installatio

Nikola Corlija 42 Dec 5, 2022
💈 Retro looking progress bar straight from the 90s

Description Do you miss the 90s? We know you do. Dial-up internet, flickering screens, brightly colored websites and, of course, this annoyingly slow

HyperRedink 18 Nov 24, 2022
Material Linear Progress Bar for your iOS apps

LinearProgressBar Material Linear Progress Bar for your iOS apps Installation Carthage: github "Recouse/LinearProgressBar" CocoaPods: Add this to you

Firdavs Khaydarov 161 Dec 5, 2022
A metaball loading written in Swift.

DBMetaballLoading Synopsis A metaball loading written in Swift. Special thanks to dodola's MetaballLoading, which is an android project. The animation

ChildhoodAndy 72 Jul 2, 2022
A beautiful activity indicator and modal alert written in Swift (originally developed for my app DoodleDoodle) Using blur effects, translucency, flat and bold design - all iOS 8 latest and greatest

SwiftSpinner SwiftSpinner is an extra beautiful activity indicator with plain and bold style. It uses dynamic blur and translucency to overlay the cur

Marin Todorov 2.1k Dec 19, 2022
The easiest way to handle a simple full screen activity indicator in iOS. Written in Swift.

LLSpinner An easy way to handle full screen activity indicator. Easy to use Get Started // Show spinner LLSpinner.spin() // Hide spinner LLSpinner.st

Aleph Retamal 36 Dec 9, 2021
Awesome loading animations using 3D engine written with Swift

RSLoadingView Introduction RSLoadingView bring your app to the new age of loading animations using 3D engine. Written with Swift Customizable Using Ap

null 419 Dec 16, 2022
This is a beauful hud view for iPhone & iPad

WSProgressHUD This is a beauful hud view for iPhone & iPad Usage To Download the project. Run the WSProgressHUD.xcodeproj in the demo directory. [

Wilson 583 Dec 6, 2022
A view class for iOS that makes uploading easy and beautiful.

SVUploader A view class for iOS that makes uploading easy and beautiful. Demo SVUploader is fully customizable - check out 2 demos. Installation Just

Kiran 79 Apr 18, 2022
Windless makes it easy to implement invisible layout loading view.

Windless Windless makes it easy to implement invisible layout loading view. Contents Requirements Installation Usage Looks Credits Communication Licen

ArLupin 940 Dec 22, 2022
Show pleasant loading view for your users 😍

RHPlaceholder ?? Because traditional loading view like UIActivityIndicatorView or similar one are no longer so trendy (Facebook or Instagram apps are

Robert Herdzik 238 Nov 2, 2022
IOS HUD Swift Library

JHProgressHUD JHProgressHUD is an iOS class written in Swift to display a translucent HUD with an indicator and/or labels while work is being done in

Harikrishnan T 79 Feb 27, 2021
Create gradients and blur gradients without a single line of code

EZYGradientView is a different and unique take on creating gradients and gradients with blur on the iOS platform. The default CAGradientLayer implemen

Shashank Pali 380 Dec 6, 2022
PBCircularProgressView is a circular progress view for iOS similar to the app store download progress view.

Overview PBCircularProgressView is a circular progress view for iOS similar to the app store download progress view. It also ha

null 0 Oct 27, 2021