(Swift) Circular progress UIView subclass with UIProgressView properties

Overview

RPCircularProgress

Coverage Status Build Status MIT licensed CocoaPods Swift

⚠️ To use with Swift 2.3 please ensure you are using == 0.2.3 ⚠️

⚠️ To use with Swift 3.x please ensure you are using >= 0.3.0 ⚠️

⚠️ To use with Swift 4.x please ensure you are using >= 0.4.0 ⚠️

⚠️ To use with Swift 4.2 please ensure you are using >= 0.4.1 ⚠️

⚠️ To use with Swift 5.0 please ensure you are using >= 0.5.0 ⚠️

UIView subclass written in Swift to show circular progress.

Example Usage

Is your app using it? Let me know!

Please see the included example app for sample usage.

Styles

  • Indeterminate (spins infinitely)
  • Normal (set progress between 0.0 and 1.0)
  • Mixed (can make it indeterminate, but also animate progress to 1.0)

Public API

/**
 Enables or disables the indeterminate (spinning) animation

 - parameter enabled:    Whether or not to enable the animation (defaults to `true`)
 - parameter completion: An optional closure to execute after the animation completes
 */
open func enableIndeterminate(_ enabled: Bool = true, completion: CompletionBlock? = nil) {}
/**
 Updates the progress bar to the given value with the optional properties

 - parameter progress:     The progress to update to, pinned between `0` and `1`
 - parameter animated:     Whether or not the update should be animated (defaults to `true`)
 - parameter initialDelay: Sets an initial delay before the animation begins
 - parameter duration:     Sets the overal duration that the animation should complete within
 - parameter completion:   An optional closure to execute after the animation completes
 */
open func updateProgress(_ progress: CGFloat, animated: Bool = true, initialDelay: CFTimeInterval = 0, duration: CFTimeInterval? = nil, completion: CompletionBlock? = nil) {}

Properties

Note: Most properties below are @IBInspectable, but I don't use Interface Builder personally so let me know if you see any issues.

var trackTintColor: UIColor

  • The color of the empty progress track (gets drawn over)

var progressTintColor: UIColor

  • The color of the progress bar

var innerTintColor: UIColor?

  • The color the notched out circle within the progress area (if there is one)

var roundedCorners: Bool

  • Sets whether or not the corners of the progress bar should be rounded

var thicknessRatio: CGFloat

  • Sets how thick the progress bar should be (pinned between 0.01 and 1)

var clockwiseProgress: Bool

  • Sets whether or not the animation should be clockwise

var timingFunction: CAMediaTimingFunction

  • A timing function defining the pacing of the animation. Defaults to ease in, ease out.

var progress: CGFloat

  • Getter for the current progress (not observed from any active animations)

var indeterminateProgress: CGFloat

  • Sets how much of the progress bar should be filled during an indeterminate animation, pinned between 0.05 and 0.9
  • Note: This can be overriden / animated from by using updateProgress(...)

var indeterminateDuration: CFTimeInterval

  • Controls the speed at which the indeterminate progress bar animates

Supports

Swift, ARC & iOS 8+, Autolayout or springs and struts

A little help from my friends

Please feel free to fork and create a pull request for bug fixes or improvements, being sure to maintain the general coding style, adding tests, and adding comments as necessary.

Credit

This library is effectively a Swift port of DACircularProgress with some minor changes to the API, so it should be fairly easy to act as a replacement. I really loved that library but unfortunately it wasn't being maintained.

Comments
  • Update CocoaPods to v1.0.1 instead of 0.39

    Update CocoaPods to v1.0.1 instead of 0.39

    If one tries to do a pod update (to install Pods) in your Example app directory, you'll likely see this error:

    myke$ pod update
    Update all pods
    Re-creating CocoaPods due to major version update.
    Setting up CocoaPods master repo
    Setup completed
    Updating local specs repositories
    Analyzing dependencies
    [!] The dependency `SnapKit` is not used in any concrete target.
    The dependency `Quick` is not used in any concrete target.
    The dependency `Nimble` is not used in any concrete target.
    

    It turns out that each Pod requires a target.

    Changing the Podfile to specify targets for pods results in this:

    myke$ pod update
    Update all pods
    Re-creating CocoaPods due to major version update.
    Updating local specs repositories
    Analyzing dependencies
    Downloading dependencies
    Installing Nimble (4.1.0)
    Installing Quick (0.9.2)
    Installing SnapKit (0.21.1)
    Generating Pods project
    Integrating client project
    Sending stats
    Pod installation complete! There are 3 dependencies from the Podfile and 3 total pods installed.
    

    I also updated the .gitignore file to ignore those pesky .DS_Store files.

    The project file also got magically regenerated in the process as well.

    opened by dautermann 5
  • Question: Start Progress

    Question: Start Progress

    Is there currently an easy way to start the progress animation from lets say .3 to the updated progress?

    I am able to get this functionality from changing the current progress in updateProgress to something other than 0 but I figured that I would ask to see if there is better way to do this

    opened by tdouglas1313 4
  • libswiftXCTest.dylib   Reason: image not found

    libswiftXCTest.dylib Reason: image not found

    I am getting this wierd crash right after installing this as a pod and running the application

    dyld: Library not loaded: @rpath/XCTest.framework/XCTest Referenced from: /Users/colworx/Library/Developer/CoreSimulator/Devices/8F5D5AC5-3A58-4577-AAC1-BA1A170D728C/data/Containers/Bundle/Application/E1DE38E0-B483-4CD5-A6E8-2665EF17EEAB/squad.app/Frameworks/libswiftXCTest.dylib Reason: image not found

    opened by samsidd 1
  • Remove use of casting to implicitly unwrapped optional

    Remove use of casting to implicitly unwrapped optional

    This pull request contains a change to fix the use of casting to an implicitly unwrapped optional. This will be deprecated in a future Swift release, and this also removes this warning when using this library.

    opened by axtonpitt 1
  • This can lead to engine corruption and weird crashes

    This can lead to engine corruption and weird crashes

    This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.

    invalid 
    opened by ashish12s3 1
  • UpdateProgress not available from Objective C

    UpdateProgress not available from Objective C

    There is no UpdateProgress: method in RPCircularProgress-Swift.h. Also the "progress" property is readonly. How can I set a progress value from within Objective C project?

    opened by Denages 1
  • Dot Appears every time updateProgress is called.

    Dot Appears every time updateProgress is called.

    I've added a RPCircularProgress to my view controller via storyboard, and in the view controller's class, I call updateProgress, a white dot appears on the screen. The dot actually moves with the bar as it fills up. I'm using the Swift 2.3 version with the AnimationDelegate commented out as CAAnimation isn't supported by Swift 2.1.

    opened by mmasque 1
  • Swift 3 to Objc Generated interface

    Swift 3 to Objc Generated interface

    Im trying to use in an old project (Objc one) the library, but i notice that the generated interface didn't show all the methods ( the ones at the extensions).

    Basically I invoke the method updateProgress

    opened by david2Coders 1
  • Pausing / resuming animation

    Pausing / resuming animation

    Question

    From an issue via email:

    How do I pause and resume an animation (i.e. one that's in the middle of animating)?

    Answer

    Read Apple's technical note here: https://developer.apple.com/library/content/qa/qa1673/_index.html

    e.g.

    func pauseAnimation() {
      var pausedTime = layer.convertTime(CACurrentMediaTime(), fromLayer: nil)
      layer.speed = 0.0
      layer.timeOffset = pausedTime
    }
    
    func resumeAnimation() {
      var pausedTime = layer.timeOffset
      layer.speed = 1.0
      layer.timeOffset = 0.0
      layer.beginTime = 0.0
      let timeSincePause = layer.convertTime(CACurrentMediaTime(), fromLayer: nil) - pausedTime
      layer.beginTime = timeSincePause
    }
    
    question 
    opened by iwasrobbed 0
  • High CPU animating static value after updating progress

    High CPU animating static value after updating progress

    Updating progress updateProgress(1.0) calls animate() eventually leading to progressLayer.add(animation, forKey: AnimationKeys.progress)

    This leads to high CPU use due system calling draw() repeatedly even after the animation has finished and the progress is set to the final value.

    Setting animation.isRemovedOnCompletion = true fixes the issue at my end. Another work around is setting a completion handler and calling updateProgress(1.0, animated: false, ...) to kill the animation, which is not ideal.

    I'm unaware of any broader issues setting isRemovedOnCompletion so leaving this as an issue rather than pull request.

    opened by rowan-OzRunways 0
  • [StackView] Dot showing if clockwiseProgress is false

    [StackView] Dot showing if clockwiseProgress is false

    First of all, thank you for sharing your awesome work!

    While I was using your library, I noticed that I get a little dot on my view when I set clockwiseProgress = false screenshot screen shot 2018-05-24 at 6 47 31 pm

    I get this issue whether I implement it programmatically or using storyboard. It works fine if clockwiseProgress = true. I am using Swift 4, Xcode Version 9.3. Do you have any idea why this would happen?

    bug 
    opened by daniel-choi 6
  • Background execution

    Background execution

    When i press my home button to turn my app to background, my circular progress completion handler is directly executed without waiting the already set duration . Any solution ?

    bug help wanted 
    opened by skander300 1
Owner
rob phillips
If I only scrape a living, at least it's a living worth scraping. If there's no future in it, at least it's a present worth remembering.
rob phillips
Step-by-step progress view with labels and shapes. A good replacement for UIActivityIndicatorView and UIProgressView.

StepProgressView Step-by-step progress view with labels and shapes. A good replacement for UIActivityIndicatorView and UIProgressView. Usage let progr

Yonat Sharon 340 Dec 16, 2022
Completely customizable progress based loaders drawn using custom CGPaths written in Swift

FillableLoaders Completely customizable progress based loaders drawn using custom CGPaths written in Swift Waves Plain Spike Rounded Demo: Changelog:

Pol Quintana 2.1k Dec 31, 2022
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
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
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
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
Snake Progress shows circular progress for iOS Apps.

SnakeProgress SnakeProgress shows circular progress for iOS Apps. With SnakeProgress With SnakeProgress, you can easily circular progress. @IBOutlet w

null 8 Sep 22, 2022
📊 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
Step-by-step progress view with labels and shapes. A good replacement for UIActivityIndicatorView and UIProgressView.

StepProgressView Step-by-step progress view with labels and shapes. A good replacement for UIActivityIndicatorView and UIProgressView. Usage let progr

Yonat Sharon 340 Dec 16, 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
📊 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
Step-by-step progress view with labels and shapes. A good replacement for UIActivityIndicatorView and UIProgressView.

StepProgressView Step-by-step progress view with labels and shapes. A good replacement for UIActivityIndicatorView and UIProgressView. Usage let progr

Yonat Sharon 340 Dec 16, 2022