• Stars
    star
    2,184
  • Rank 21,123 (Top 0.5 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 10 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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.

More Repositories

1

EasyAnimation

A Swift library to take the power of UIView.animateWithDuration(_:, animations:...) to a whole new level - layers, springs, chain-able animations and mixing view and layer animations together!
Swift
2,960
star
2

Timelane

Timelane
Swift
706
star
3

TaskQueue

A Task Queue Class developed in Swift (by Marin Todorov)
Swift
681
star
4

UIEffectDesignerView

A native Particle Systems effect view for iOS and OSX powered by QuartzCore
Objective-C
617
star
5

Retry

Haven't you wished for `try` to sometimes try a little harder? Meet `retry`
Swift
498
star
6

EventBlankApp

A free open source iOS app for events or conferences. Read more on the app's webpage:
Swift
291
star
7

MTLog

NSLog replacement for coders!
Objective-C
222
star
8

Breadcrumbs

Bugtracker working off source code
Swift
193
star
9

TimelaneCombine

Timelane + Combine
Swift
168
star
10

RxTimelane

Timelane + RxSwift
Swift
132
star
11

PowerUpYourAnimations

Sample code from talks on advanced animations
Swift
118
star
12

DoNilDisturbPlugin

A plugin for your Xcode project that stops you from working outside work hours
Swift
109
star
13

timeui

Profile apps from the command line — duration, cpu & memory usage.
Swift
107
star
14

OneShotLocationManager

A replacement class for CLLocationManager for when you want to easily fetch the current device location
Swift
101
star
15

MTPopupWindow

Popup-window style view for Objective-C, which loads contents of an HTML file. Easy one-line usage. Check the readme for example
Objective-C
84
star
16

TimelaneCore

Timelane + Core
Swift
66
star
17

OperationTimelane

Timelane + Operations
Swift
45
star
18

RxSwiftoniOS

Sample code from my dotSwift 2017 talk in Paris
Swift
43
star
19

PackageView

An app that displays Package.swift info
Swift
42
star
20

RealmGitHubSearchRxDemo

The demo app for RxRealm's post on realm.io
Swift
36
star
21

RealmMultiplatformDemo

Demo that shares its model layer across Apple's four platforms
Swift
36
star
22

Advanced-RSS-reader

An example of an RSS reader app for iPhone, full source and comments
Objective-C
34
star
23

MTTestSemaphore

A class to help you create unit tests that test asynchronous methods. You will need this to unit test any class that fetch data from the network, use location, camera, etc.
Objective-C
33
star
24

Unxippity

Unxips quickly Xcode downloads
Swift
32
star
25

Cancellor

Bind multiple cancellables to the lifetime of another object like a view controller.
Swift
32
star
26

RealmNotificationExample

The project for the post demonstrating fine grained notifications on realm.io
Swift
30
star
27

MarkWalkthrough

A SwiftUI package to quickly build app walkthroughs
Swift
27
star
28

HUD

Beautiful alert message/ progress hud component for iOS Objective-C
Objective-C
25
star
29

SafariDownload

Swift package to read Safari's download packages
Swift
8
star
30

CustomInstrument

A custom Xcode instrument based on Timelane
Swift
7
star
31

Fetch-and-parse-JSON

Fetch and parse JSON
Objective-C
7
star
32

ActorBench

Actor vs queue vs lock benchmark
Swift
6
star
33

TimelaneInstrument

Timelane Tools Instrument
5
star
34

StylesDemoApp

A little experiment on styling SwiftUI views
Swift
4
star
35

powerups

cli for dynamic XML includes
Swift
3
star
36

nsspain2020

Demo projects from my talk at NSSpain 2020
Swift
3
star
37

Tracker

Google Analytics iOS shortcut wrapper
3
star
38

TimerApp

Timer App v1
Swift
3
star
39

LogRider

Logs viewer app for mac
Swift
3
star
40

snippetty.io

snippetty.io
HTML
3
star
41

HTTPKit

Task based, promise like syntax, RESTful, HTTP library for iOS and OS X. Built off ConcurrentKit and NSURLSession.
Objective-C
2
star
42

react-native-console-oslog

React Native package to log to Apple's unified log
Objective-C++
2
star
43

rx-marin

rx blog:
HTML
2
star
44

combinebook.com

HTML
2
star
45

ios-animations-by-emails

iOS Animations by Emails newsletter archive
HTML
2
star
46

snippety.io

snippetty.io
1
star
47

swiftconcurrencybook

swiftconcurrencybook.com
CSS
1
star
48

AnagramsGameiPad

The completed source code to "How to create an awesome Anagrams game with UIKit"
Objective-C
1
star
49

Baffle

Ruby
1
star
50

www.timelane.tools

www.timelane.tools
1
star
51

macro-bad-access

Swift
1
star
52

tryCombine

tryCombine blog by Marin Todorov
HTML
1
star
53

Languages

RWDevCon tutorial code
Swift
1
star