Welcome to the documentation for FGHUD!
FGHUD is a comprehensive and customizable Heads-Up Display (HUD) library for iOS and macOS applications. Here, you will find detailed information and examples on how to integrate and utilize the FGHUD library in your projects.
Installation
To add FGHUD to your project, follow these steps:
- Open your project in Xcode.
- Navigate to your target’s settings.
- Select “General” and scroll down to the “Frameworks, Libraries, and Embedded Content” section.
- Click on the “+” button to add a new library.
- Search for “FGHUD” and select the version you want to add.
- Click “Add” to add FGHUD to your project.
Quick Start
Once you have added FGHUD to your project, you can start using it with just a few lines of code.
Show a HUD
To show a HUD with a simple message, use the following code:
import FGHUD
FGHUD.showHUD(withMessage: "Loading...")
Customize HUD Appearance
FGHUD allows you to customize various aspects of the HUD’s appearance. Here’s an example:
FGHUD.setTextColor(.white)
FGHUD.setBackgroundColor(.black)
FGHUD.setCornerRadius(10.0)
FGHUD.setFont(UIFont.boldSystemFont(ofSize: 14.0))
FGHUD.setActivityIndicatorColor(.white)
FGHUD.showHUD(withMessage: "Loading...")
Advanced Usage
Loading Indicators
FGHUD provides various loading indicators to display progress or activity. To use a loading indicator, simply call the respective method:
FGHUD.showActivityIndicator()
You can customize the loading indicator’s color using:
FGHUD.setActivityIndicatorColor(.red)
Hiding the HUD
To hide the current HUD, use the following code:
FGHUD.hideHUD()
Displaying Success or Error Messages
Use the following methods to show success or error messages:
FGHUD.showSuccess(withMessage: "Task completed successfully!")
FGHUD.showError(withMessage: "An error occurred.")
Customizing Animation Style
FGHUD provides different animation styles for showing and hiding the HUD. You can set the animation style using:
FGHUD.setAnimationStyle(.fade) // Options: .fade, .zoom, .alpha
Troubleshooting
HUD Not Displaying
If the HUD does not display, make sure you have called the showHUD method correctly and that it is called on the main thread.
HUD Appears behind Other Views
If the HUD appears behind other views, try adjusting the view hierarchy or calling bringSubviewToFront on the relevant view.
Conclusion
Congratulations! You now know how to integrate and use FGHUD in your iOS and macOS applications. Feel free to explore the additional features and customization options provided by FGHUD to enhance your user interface.