How to create custom activity indicator in swift & swiftUI


A nice collection of awesome loading animations activity indicator in swift. If you need a simple visual way to show users that some activity is happening, UIActivityIndicatorView is the easiest approach.

ActivityIndicator is a kind of content view that can be used to show that a task is in progress. We can control the ActivityIndicator View by using methods defined in UIActivityIndicatorView class.

How to create custom activity indicator in swift & swiftUI

Animation types of Activity Indicator

1. ballPulse2. ballGridPulse3. ballClipRotate4. squareSpin
5. ballClipRotatePulse6. ballClipRotateMultiple7. ballPulseRise8. ballRotate
9. cubeTransition10. ballZigZag11. ballZigZagDeflect12. ballTrianglePath
13. ballScale14. lineScale15. lineScaleParty16. ballScaleMultiple
17. ballPulseSync18. ballBeat19. lineScalePulseOut20. lineScalePulseOutRapid
21. ballScaleRipple22. ballScaleRippleMultiple23. ballSpinFadeLoader24. lineSpinFadeLoader
25. triangleSkewSpin26. pacman27. ballGridBeat28. semiCircleSpin
29. ballRotateChase30. orbit31. audioEqualizer32. circleStrokeSpin



Cocoapods is a dependency manager for Swift and Objective-C Cocoa projects. To use NVActivityIndicatorView with CocoaPods, add it in your Podfile.

pod 'NVActivityIndicatorView'


Carthage is intended to be the simplest way to add frameworks to your Cocoa application. To use NVActivityIndicatorView with Carthage, add it in your Cartfile.

github "ninjaprox/NVActivityIndicatorView"

Swift Package Manager

The Swift Package Manager is a tool for managing the distribution of Swift code. To use NVActivityIndicatorView with Swift Package Manger, add it to dependencies in your Package.swift

dependencies: [
    .package(url: "")


Firstly, import NVActivityIndicatorView.

import NVActivityIndicatorView


Then, there are two ways you can create NVActivityIndicatorView:

  • By storyboard, changing class of any UIView to NVActivityIndicatorView.

Note: Set Module to NVActivityIndicatorView.

  • By code, using initializer. All parameters other than frame are optional and NVActivityIndicatorView.DEFAULT_*  are used as default values.
NVActivityIndicatorView(frame: frame, type: type, color: color, padding: padding)


Start animating.


Stop animating.


Determine if it is animating.

animating = activityIndicatorView.isAnimating

Change properties

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 after initializing.

Note: All changes must be made before calling startAnimating().





NVActivityIndicatorView implemented in SwiftUI.

ActivityIndicatorView implemented in SwiftUI.



Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *