Welcome to the documentation for AmpActivityIndicator library.
Introduction
AmpActivityIndicator is a lightweight library that provides a set of customizable activity indicators for iOS applications. It is designed to provide feedback to the user when performing time-consuming tasks or loading data.
Features
- Support for various activity indicator types
- Customizable appearance and size
- Easy integration with existing UIKit components
- Supports both programmatic and interface builder usage
Requirements
AmpActivityIndicator library has the following requirements:
- iOS 13.0 or later
- Xcode 12.0 or later
- Swift 5.0 or later
Installation
To install AmpActivityIndicator in your project, you have multiple options:
Swift Package Manager
You can use Swift Package Manager to easily integrate AmpActivityIndicator into your project. Follow these steps:
- In Xcode, open your project and navigate to the target to which you want to add AmpActivityIndicator.
- Go to the “Swift Packages” tab in the project settings.
- Click the “+” button to add a new package.
- Enter the URL of the AmpActivityIndicator GitHub repository (https://github.com/username/repo) and click “Next”.
- Select the desired version rule and click “Next”.
- Choose the target to which you want to add AmpActivityIndicator and click “Finish”.
Manual Installation
If you prefer manual installation, follow these steps:
- Download the latest release of AmpActivityIndicator from the GitHub repository: https://github.com/username/repo
- Drag the AmpActivityIndicator.framework file into your Xcode project.
- In the project settings, go to the “General” tab and add AmpActivityIndicator.framework under “Frameworks, Libraries, and Embedded Content”.
- Make sure to select “Embed & Sign” under the “Embed” column.
Usage
Adding an Activity Indicator programmatically
In your View Controller, you can add an AmpActivityIndicator programmatically by following these steps:
import AmpActivityIndicator
class MyViewController: UIViewController {
var activityIndicator: AmpActivityIndicator!
override func viewDidLoad() {
super.viewDidLoad()
// Initialize the activity indicator
activityIndicator = AmpActivityIndicator()
// Customize the appearance
activityIndicator.color = .red
activityIndicator.style = .large
// Add the activity indicator to your view
self.view.addSubview(activityIndicator)
// Position the activity indicator in your view
activityIndicator.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
activityIndicator.centerXAnchor.constraint(equalTo: view.centerXAnchor),
activityIndicator.centerYAnchor.constraint(equalTo: view.centerYAnchor)
])
// Start animating the activity indicator
activityIndicator.startAnimating()
// Stop animating the activity indicator
// activityIndicator.stopAnimating()
}
}
Using an Activity Indicator in Interface Builder
If you prefer using Interface Builder to add an AmpActivityIndicator, follow these steps:
- Drag a generic view onto your View Controller in the storyboard.
- In the Identity inspector, set the custom class to AmpActivityIndicator.
- Customize the appearance of the activity indicator using the Attributes inspector.
- Connect the activity indicator to your View Controller by creating an IBOutlet.
- Start and stop animating the activity indicator programmatically by accessing its properties.
Customization
AmpActivityIndicator provides a range of options to customize the appearance and behavior of the activity indicators. Here are some customization options:
Appearance customization
You can customize the following appearance properties of an AmpActivityIndicator:
- color: The color of the activity indicator.
- style: The style of the activity indicator (small, medium, large).
- backgroundStyle: The background style for the activity indicator (none, translucent, opaque).
- cornerRadius: The corner radius of the activity indicator.
Behavior customization
You can customize the following behavior properties of an AmpActivityIndicator:
- isHidden: A boolean value that controls whether the activity indicator is hidden.
- isAnimating: A boolean value that controls whether the activity indicator is animating.
- startAnimating(): Starts animating the activity indicator.
- stopAnimating(): Stops animating the activity indicator.
- hidesWhenStopped: A boolean value that controls whether the activity indicator is hidden when not animating.
License
AmpActivityIndicator is released under the MIT License. See the LICENSE file for more details.
For more information, bug reports, and feature requests, visit the GitHub repository.