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

Overview

SwiftSpinner

Version License Platform Swift 5.0

SwiftSpinner is an extra beautiful activity indicator with plain and bold style. It uses dynamic blur and translucency to overlay the current screen contents and display an activity indicator with text (or the so called “spinner”).


I developed it for my Swift app called Doodle Doodle and wanted to share it with everyone.

This is how the activity looks like (from the demo app):

SwiftSpinner Screenshot

Usage

To run the example project, clone the repo, and run pod install from the DemoApp directory first. That’ll run the demo program which shows you how the spinner looks like and what it can do.

Code samples

The simple code to get SwiftSpinner running in your own app.

  • In case you installed SwiftSpinner via CocoaPods you need to import it (add this somewhere at the top of your source code file):
import SwiftSpinner
  • When you want to show an animated activity (eg. rings are randomly rotating around):
SwiftSpinner.show("Connecting to satellite...")
  • If you want to show a static activity indicator (eg. a message with two complete rings around it)
SwiftSpinner.show("Failed to connect, waiting...", animated: false)
  • When you want to hide the activity:
SwiftSpinner.hide()

In case you want to do something after the hiding animation completes you can provide a closure to the hide() method:

SwiftSpinner.hide({
  //do stuff
})

That's all. If you want to change the text of the current activity, just call show(...) again, this will animate the old text into the new text.

Beyond the basics

If you are using SwiftSpinner to show an alert message you can also easily add a dismiss handler:

SwiftSpinner.show("Connecting \nto satellite...").addTapHandler({
  SwiftSpinner.hide()
})

Or even add a subtitle to let the user know they can tap to do stuff:

SwiftSpinner.show("Connecting \nto satellite...").addTapHandler({
  SwiftSpinner.hide()
}, subtitle: "Tap to hide while connecting! This will affect only the current operation.")

In case you want to adjust the font of the spinner title:

SwiftSpinner.setTitleFont(UIFont(name: "Futura", size: 22.0))

To reset back to the default font:

SwiftSpinner.setTitleFont(nil)

In case you want to change an arbitrary aspect of the text on screen access directly:

SwiftSpinner.shared.titleLabel
SwiftSpinner.shared.subtitleLabel

You can show a spinner only if certain amount of time has passed (e.g. if you are downloading a file - show a message only if the operation takes longer than certain amount of time):

SwiftSpinner.show(delay: 2.0, title: "It's taking longer than expected")

If you call show(…) or hide() before the delay time has passed - this will clear the call to show(delay: …).

You show a message for a certain duration:

SwiftSpinner.show(duration: 4.0, title: "It's taking longer than expected")

Or you can use SwiftSpinner as a progress bar by directly setting the current progress like so:

SwiftSpinner.show(progress: 0.2, title: "Downloading Data...") // 20% trough the process

If you want to see the content behind the spinner, set the showBlurBackground to false:

SwiftSpinner.showBlurBackground = false

Requirements

UIKit must be imported. If you are using SwiftSpinner in an App Extension, you must add EXTENSION to your Other Swift Flags Build Settings.

Extension Setting Screenshot

Installation

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

pod "SwiftSpinner"

In case you don’t want to use CocoaPods - just copy the file SwiftSpinner/SwiftSpinner.swift to your Xcode project.

Credit

Author: Marin Todorov

More about Marin:


iOS Animations by Tutorials, Author

iOS Animations by Emails Newsletter, Author

License

SwiftSpinner is available under the MIT license. See the LICENSE file for more info.

Comments
  • Don't adjust when orientation changed

    Don't adjust when orientation changed

    If we change the device orientation when the spinner is showed, the spinner don't adjust it self for the hole screen. (tested in real iphone 4S device) spinner bug

    working on it 
    opened by ziedmahdi 13
  • SwiftSpinner.show(duration: 2.0, ...) cannot be canceled

    SwiftSpinner.show(duration: 2.0, ...) cannot be canceled

    Hi,

    I found that SwiftSpinner.show(duration: 2.0, title: "Connected", animated: false) cannot be canceled by SwiftSpinner.show("Connected", animated: false).

    E.g. SwiftSpinner.show(duration: 2.0, title: "Connected", animated: false) SwiftSpinner.show("Connecting...").

    What I want to do is making it shows 'Connecting' all the time. However, it shows "Connected" firstly (it disappears very quickly so we cannot see, that is fine), then it shows "Connecting..." and it disappears after 2 seconds.

    The reason is that the first function calls SwiftSpinner.hide() after 2 seconds and there is no way to cancel it. So whatever I did after I call show(duration:...), it will hide the SwiftSpinner after the duration. Is there any way that I can cancel the duration action after calling it?

    Regards,

    Daniel

    opened by danielpluvia 9
  • Can't use without crashing after update

    Can't use without crashing after update

    I updated from 1.0.4 to 1.1.0 and now I get a crash when launching the spinner, I tried all versions up to the latest

    [SwiftSpinner.SwiftSpinner setUserInteractionEnabled:]: unrecognized selector sent to class 0x10c14c750
    2018-11-21 11:33:13.501015-0400 CommonStock[91649:11480586] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[SwiftSpinner.SwiftSpinner setUserInteractionEnabled:]: unrecognized selector sent to class 0x10c14c750'
    
    opened by SolorzanoJose 8
  • Set inner/outer color back to default

    Set inner/outer color back to default

    After using the following:

    SwiftSpinner.sharedInstance.innerColor = UIColor.red
    SwiftSpinner.sharedInstance.outerColor = UIColor.red
            
            
    SwiftSpinner.show(duration: 1.5, title: error, animated:false)
    

    How do I reset the color back to default? Doesn't seem to be any kind of default property.

    question 
    opened by martheli 8
  • Share Xcode scheme so SwiftSpinner works with Carthage

    Share Xcode scheme so SwiftSpinner works with Carthage

    Carthage is a decentralized dependency manager that gives developers more control over how frameworks are integrated compared to CocoaPods, and is becoming increasingly popular. It uses xcodebuild to build dependancies instead of using a shared workspace, and the only requirement for frameworks is that there's a shared scheme so that the tool can discover and build it properly.

    opened by jpiche 7
  • Swift 2.0

    Swift 2.0

    I removed the pods file and fixed the error you were talking about in your emails. This project should compile and run just fine under Xcode 7 and Swift 2.0.

    opened by VasuLaroiya 7
  • Pod stuck at Swift v3.2

    Pod stuck at Swift v3.2

    I was migrating a project using Swift 3.2 over to 4 and then 5, but at every stage the SwiftSpinner pod remains at Swift version 3.2, even after doing things like pod deintegrate and deleting the .xcworkspace file and the Podfile.lock file. Is there something else I can do besides manually having to update the language version within Xcode for the pod?

    pod "SwiftSpinner", '~> 2.1.0'

    opened by gee4vee 6
  • Converted to Swift 2.0

    Converted to Swift 2.0

    I converted the SwiftSpinner.swift file to Swift 2.0. I also converted the Demo Project to a Xcode 7 project. The pod file wasn’t working for me so I changed it to get the SwiftSpinner from the cocoapod you have setup.

    opened by VasuLaroiya 6
  • EXC_BAD_ACCESS

    EXC_BAD_ACCESS

    I recently included this pod into our project. However, we're seeing a 'Thread 1: EXC_BAD_ACCESS (code=1, address=0x1cd)' when trying to show the spinner.

    Any thoughts on what might be causing this?

    screen shot 2017-01-09 at 2 36 01 pm

    opened by djneely 5
  • spinner loses custom font when calling

    spinner loses custom font when calling "show" method next time

    after setting a custom font using setTitleFont method, the custom font works only the first time the spinner is displayed, however, the spinner switches back to the default font next time I have the "show" method

    opened by murad1981 5
  • Spinner not shown when called from AppDelegate

    Spinner not shown when called from AppDelegate

    I have no problem showing the Swift spinner from any function/view controller except AppDelegate. The problem comes only when I call SwiftSpinner.show("Loading...") from AppDelegate. I have set breakpoints and checked. The show() function in SwiftSpinner.swift is getting called and executed. But the spinner is not shown on the window. I have also updated the code with this https://github.com/MMasterson/SwiftSpinner/commit/68e718bb8a675d0a92dba37ecfa57ec0e39c73fa . But still same problem. Anyone has any solution for this?

    opened by deepika1203 5
  • image not found

    image not found

    Hi,

    I'm getting this error when I try to import SwiftSpinner.

    Any suggestions?

    dyld: dyld cache load error: shared cache file open() failed dyld: Library not loaded: @rpath/SwiftSpinner.framework/SwiftSpinner Referenced from: /Users/me/Library/Developer/CoreSimulator/Devices/A99A09BF-5A18-45E6-A0F3-CB3F9EF2EB75/data/Containers/Bundle/Application/0D1F8ACB-0577-4A4D-93CA-7B984E914BBF/ShoeAuth.app/ShoeAuth Reason: image not found dyld: launch, loading dependent libraries

    opened by rgagnon 1
  • inputAcessoryView is always displayed above SwiftSpinner

    inputAcessoryView is always displayed above SwiftSpinner

    I'm currently working with a UIViewController which has a custom inputAcessoryView, as in

    override var inputAccessoryView: UIView {
            return myInputAccessoryView
        }
    

    The problem is that, in this case, the inputAccessoryView is always displayed above the SwiftSpinner. Is this by design, a bug, or is it something a can tweak either in my acessoryView or in how I call SwiftSpinner?

    opened by alezoffoli 2
  • Is there any possible way to change the circle's height?

    Is there any possible way to change the circle's height?

    I find the circles are huge for my screen and I want to change the sizes of circles, but I didn't succeed. I tried to change frameSize value in framework(SwiftSpinner) (h:200,w:200) to (h:100,w:100) but it didn't work as I expected. Actually nothing changed, sizes were still same.

    By the way I really like the SwiftSpinner, in my opinion it's a cool framework to use.

    opened by GokmenAkarDNB 3
  • SwiftSpinner.hide() doesn't work on multiple push/pop view controllers.

    SwiftSpinner.hide() doesn't work on multiple push/pop view controllers.

    Really weird issue where if I'm coming in and out of a view controller via a navigationController.popToRootController and a navigationController.pushViewController, the 2nd time the SwiftSpinner.hide() doesn't hide the view. I'd have to call it twice

    SwiftSpinner.hide() SwiftSpinner.hide()

    then if I do the push/pop thing again, it still has an issue and I would have to call it 3 times. It's as if each time the view controller pops/pushes it's adding another SwiftSpinner.show() for whatever reason.

    opened by tomengland 1
  • not responding when using inside NSManagedObjectContext.perform{}

    not responding when using inside NSManagedObjectContext.perform{}

    my code looks like this

        let bgContext = NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
    
    
        func doCoreData(progress : @escaping (Double) -> ()) {
            bgContext.perform {
                for i in 1...10{
                    let cent : Double = Double(i)/Double(10)
                    // do some coredata work adding and updating
                    progress(cent)
                }
            }
        }
        
        func orgnizeThings (){
            doCoreData { (cent) in
                DispatchQueue.main.async {
                    let perCent = cent * 100
                    SwiftSpinner.show(progress: cent, title: "loading \(perCent)")
                }
            }
        }
    

    calling the orgnizeThings() function will get the core data work done but I would like to to show the user how far the function is done

    in this setup the SwiftSpinner view is frozen

    opened by turk-jk 1
Releases(2.0.0)
Owner
Marin Todorov
Experienced on  platforms. Author of "Modern Concurrency in Swift", "Combine: Asynchronous Programming with Swift", and others.
Marin Todorov
A lightweight and awesome loading Activity Indicator for your iOS app.

BPCircleActivityIndicator BPCircleActivityIndicator is a clean and easy-to-use Activity Indicator meant to display the progress of an ongoing task on

Ben.Park 46 Aug 12, 2022
A simple and awesome loading Activity Indicator(with block moving animation) for your iOS app.

BPBlockActivityIndicator BPBlockActivityIndicator is a clean and easy-to-use Activity Indicator meant to display the progress of an ongoing task on iO

Ben.Park 43 Nov 6, 2021
Yet another task indicator

SendIndicator Yet another task indicator Requirements Installation Usage License Requirements iOS 8.0+ Swift 3.0+ Xcode 8.0+ Installation CocoaPods Co

Leonardo Cardoso 64 Aug 17, 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
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
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
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
StatusBarOverlay will automatically show a "No Internet Connection" bar when your app loses connection, and hide it again

StatusBarOverlay will automatically show a "No Internet Connection" bar when your app loses connection, and hide it again. It supports apps which hide the status bar and The Notch

Idle Hands Apps 160 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
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
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 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
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
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
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
☠️ An elegant way to show users that something is happening and also prepare them to which contents they are awaiting

Features • Guides • Installation • Usage • Miscellaneous • Contributing ?? README is available in other languages: ???? . ???? . ???? . ???? . ???? To

Juanpe Catalán 11.7k Jan 8, 2023
👨‍💻Watch the latest and greatest conference videos on your Mac

Conferences.digital is the best way to watch the latest and greatest videos from your favourite developer conferences for free on your Mac. Either sea

Timon Blask 768 Jan 4, 2023
A Full News App based on the latest SwiftUI 3/iOS 15 API that fetches latest news from newsapi.org

SwiftUI NewsAPI App A Full News App based on the latest SwiftUI 3/iOS 15 that fetches latest news from newsapi.org. Features The app has several main

Alfian Losari 139 Jan 2, 2023