NVActivityIndicatorView
is a collection of awesome loading animations.
This is original a fork from DGActivityIndicatorView, inspired by Loaders.css, written in Swift with full implementation of animations, plus more.
You can also find Objective-C version of this here.
For first-hand experience, just open the project and run it.
Type | Type | Type | Type |
---|
- BallPulse | 2. BallGridPulse | 3. BallClipRotate | 4. SquareSpin
- BallClipRotatePulse | 6. BallClipRotateMultiple | 7. BallPulseRise | 8. BallRotate
- CubeTransition | 10. BallZigZag | 11. BallZigZagDeflect | 12. BallTrianglePath
- BallScale | 14. LineScale | 15. LineScaleParty | 16. BallScaleMultiple
- BallPulseSync | 18. BallBeat | 19. LineScalePulseOut | 20. LineScalePulseOutRapid
- BallScaleRipple | 22. BallScaleRippleMultiple | 23. BallSpinFadeLoader | 24. LineSpinFadeLoader
- TriangleSkewSpin | 26. Pacman | 27. BallGridBeat | 28. SemiCircleSpin
- BallRotateChase | 30. Orbit | 31. AudioEqualizer
Install Cocoapods if need be.
$ gem install cocoapods
Add NVActivityIndicatorView
in your Podfile
.
use_frameworks!
pod 'NVActivityIndicatorView'
Then, run the following command.
$ pod install
Install Carthage if need be.
$ brew update
$ brew install carthage
Add NVActivityIndicatorView
in your Cartfile
.
github "ninjaprox/NVActivityIndicatorView"
Run carthage
to build the framework and drag the built NVActivityIndicatorView.framework
into your Xcode project.
Copy NVActivityIndicatorView
folder to your project. That's it.
Note: Make sure that all files in NVActivityIndicatorView
included in Compile Sources in Build Phases.
This version requires Xcode 8.0 and Swift 3.
NVActivityIndicatorView.startAnimation()
andNVActivityIndicatorView.stopAnimation()
are deleted. UseNVActivityIndicatorView.startAnimating()
andNVActivityIndicatorView.stopAnimating()
instead.UIViewController.startActivityAnimating()
andUIViewController.stopActivityAnimating()
are deleted. UseUIViewController.startAnimating()
andUIViewController.stopAnimating()
instead.
This version continues to spport Xcode 7.0 and Swift 2.2 and earlier.
For Swift 2.3 support, use swift2.3
branch instead.
pod 'NVActivityIndicatorView', :git => 'https://github.com/ninjaprox/NVActivityIndicatorView.git', :branch => 'swift2.3'
Firstly, import NVActivityIndicatorView
.
import NVActivityIndicatorView
Then, there are two ways you can create NVActivityIndicatorView:
- By storyboard, changing class of any
UIView
toNVActivityIndicatorView
.
Note: Set Module to NVActivityIndicatorView
.
- By code, using initializer. All parameters other than
frame
are optional andNVActivityIndicatorView.DEFAULT_*
are used as default values.
NVActivityIndicatorView(frame: frame, type: type, color: color, padding: padding)
Note: Check DEFAULTS for default values.
Start animating.
activityIndicatorView.startAnimating()
Stop animating.
activityIndicatorView.stopAnimating()
Determine if it is animating.
animating = activityIndicatorView.animating
In storyboard, you can change all properties in Attributes inspector tab of Utilities panel.
Note: Use one of values (case-insensitive) in Animation types for Type Name
.
All properties are public so you can change them all after initiating.
Note: All changes must be made before calling startAnimating()
.
By conforming NVActivityIndicatorViewable
protocol, you can use NVActivityIndicatorView
as UI blocker for UIViewController
.
class ViewController: UIViewController, NVActivityIndicatorViewable { }
Start animating.
startAnimating(size, message) // plus other parameters as in initializer.
Stop animating.
stopAnimating()
Or you can use NVActivityIndicatorPresenter
to display UI blocker anywhere.
Start animating.
let activityData = ActivityData()
NVActivityIndicatorPresenter.sharedInstance.startAnimating(activityData)
Note: Check documentation for detail of ActivityData
.
Stop animating.
NVActivityIndicatorPresenter.sharedInstance.stopAnimating()
There are global defaults for all NVActivityIndicatorView
instances.
- Default animation type.
NVActivityIndicatorView.DEFAULT_TYPE = .BallSpinFadeLoader
- Default color of activity indicator view.
NVActivityIndicatorView.DEFAULT_COLOR = UIColor.whiteColor()
- Default padding of activity indicator view.
NVActivityIndicatorView.DEFAULT_PADDING = CGFloat(0)
- Default size of activity indicator view used in UI blocker.
NVActivityIndicatorView.DEFAULT_BLOCKER_SIZE = CGSizeMake(60, 60)
- Default display time threshold.
Default time that has to be elapsed (between calls of
startAnimating()
andstopAnimating()
) in order to actually display UI blocker. It should be set thinking about what the minimum duration of an activity is to be worth showing it to the user. If the activity ends before this time threshold, then it will not be displayed at all.
NVActivityIndicatorView.DEFAULT_BLOCKER_DISPLAY_TIME_THRESHOLD = 0 // in milliseconds
- Default minimum display time.
Default minimum display time of UI blocker. Its main purpose is to avoid flashes showing and hiding it so fast. For instance, setting it to 200ms will force UI blocker to be shown for at least this time (regardless of calling
stopAnimating()
ealier).
NVActivityIndicatorView.DEFAULT_BLOCKER_MINIMUM_DISPLAY_TIME = 0 // in milliseconds
Thanks Connor Atherton for great loaders and Danil Gontovnik for kick-start.
The MIT License (MIT)
Copyright (c) 2016 Vinh Nguyen @ninjaprox