Welcome to the documentation page for the NVActivityIndicatorView library! This library provides a collection of customizable and animated activity indicators for iOS applications. It is designed to give developers an easy and efficient way to add stylish loading spinners to their apps.
Installation
To use NVActivityIndicatorView in your project, you can follow the steps outlined below:
- Open your project in Xcode.
- Select your project in the Project Navigator (left sidebar).
- Go to the “General” tab and scroll down to the “Embedded Binaries” section.
- Click the “+” button, select “NVActivityIndicatorView.framework,” and click “Add.”
-
Import the library in your desired class using the following statement:
import NVActivityIndicatorView
Usage
After you have successfully installed the library, you can start using it in your project. Follow the steps below to add an activity indicator to your view.
- Select the view or container where you want to display the activity indicator.
-
Create an instance of NVActivityIndicatorView and specify the desired parameters.
activityIndicatorView = NVActivityIndicatorView(frame: CGRect(x: 0, y: 0, width: 50, height: 50), type: .ballSpinFadeLoader, color: .white, padding: nil)
Note: You can customize the frame, type, color, and padding as per your requirements.
-
Add the activity indicator to the selected view.
view.addSubview(activityIndicatorView)
-
Start animating the activity indicator.
activityIndicatorView.startAnimating()
Customization
NVActivityIndicatorView allows you to customize various aspects of the activity indicators. Below is a list of customization options available:
- Type: Specifies the style of the activity indicator, such as ball, line, circle, etc.
- Color: Sets the color of the activity indicator.
- Padding: Applies padding around the activity indicator.
- Background color: Defines the background color of the activity indicator view.
- Number of rotations: Determines how many rotations the activity indicator performs during animation.
Examples
Need some inspiration to get started? Below are a few code snippets showcasing different use cases:
Example 1 – Simple Activity Indicator
This example demonstrates how to create a basic activity indicator and add it to a view.
let frame = CGRect(x: 0, y: 0, width: 50, height: 50) let indicatorType = NVActivityIndicatorType.ballPulse let color = UIColor.white let padding: CGFloat? = nil let activityIndicatorView = NVActivityIndicatorView(frame: frame, type: indicatorType, color: color, padding: padding) view.addSubview(activityIndicatorView) activityIndicatorView.startAnimating()
Example 2 – Customized Activity Indicator
This example demonstrates how to create a customized activity indicator with a pink color and increased padding.
let frame = CGRect(x: 0, y: 0, width: 60, height: 60) let indicatorType = NVActivityIndicatorType.ballClipRotatePulse let color = UIColor.systemPink let padding: CGFloat? = 20 let activityIndicatorView = NVActivityIndicatorView(frame: frame, type: indicatorType, color: color, padding: padding) view.addSubview(activityIndicatorView) activityIndicatorView.startAnimating()
Conclusion
Congratulations! You have learned how to integrate and use NVActivityIndicatorView library in your iOS application. Now you can add beautiful and customizable activity indicators to enhance the user experience in your app.
If you have any further questions or need additional information, feel free to visit the official NVActivityIndicatorView documentation.