Introduction to MrProgress
MrProgress is a lightweight progress HUD (Heads-Up Display) framework written in Objective-C for iOS development. It allows developers to easily incorporate visually appealing progress indicators in their applications to enhance user experience.
Installation
Follow the below steps to install MrProgress in your iOS project:
- Open your project in Xcode
- Go to File -> Swift Packages -> Add Package Dependency
- Enter the following URL: https://github.com/mrackwitz/MRProgress.git
- Select the desired version of MrProgress and click Next
- Choose the target you want to add MrProgress to and click Finish
Usage
To use MrProgress in your application, follow the steps below:
- Import the MrProgress framework into your view controller:
- Create an instance of MRProgressOverlayView:
- Customize the progress view appearance (optional):
- Show or hide the progress view:
import MRProgress
let progressView = MRProgressOverlayView.showOverlayAdded(to: self.view, title: "Loading", mode: .determinateCircular, animated: true)
progressView.tintColor = .blue
progressView.backgroundColor = .white
progressView.setTitleColor(.black, for: .normal)
progressView.show(animated: true)
progressView.dismiss(animated: true)
Customization
MrProgress provides various customization options to personalize the progress indicators according to your preferences. You can modify the following attributes:
- TintColor: Specifies the color of the progress view.
- BackgroundColor: Sets the background color of the progress view.
- TitleColor: Defines the text color of the progress view title.
Use the provided properties of MRProgressOverlayView to customize the appearance of the progress view as demonstrated in the usage section above.
Examples
Below are some examples that showcase different types of progress indicators:
Circular Progress Indicator
Linear Progress Indicator
Completion Handler
let progressView = MRProgressOverlayView.showOverlayAdded(to: self.view, title: "Loading", mode: .determinateCircular, animated: true) { completed in
if completed {
print("Task completed successfully.")
} else {
print("An error occurred while performing the task.")
}
}
The completion handler allows you to execute additional code based on the completion of a task. It provides a boolean parameter indicating the success of the task.
Conclusion
MrProgress simplifies the implementation of progress HUDs in your iOS application, enhancing the user experience. By following the installation and usage steps mentioned above, you can easily incorporate visually appealing progress indicators in your project. Remember to customize the progress view as desired and explore the various customization options available. Happy coding!