FlyHUD
FlyHUD copied to clipboard
A lightweight and easy-to-use HUD for iOS and tvOS apps.
English | 简体中文
This is a lightweight and easy-to-use HUD designed to display the progress and status of ongoing tasks on iOS and tvOS.
ScreenShots
Requirements
- iOS 12.0+
- tvOS 12.0+
- Xcode 14.1+
- Swift 5.7.1+
Installation
Swift Package Manager
...using swift build
If you are using the Swift Package Manager, add a dependency to your Package.swift
file and import the HUD library into the desired targets:
dependencies: [
.package(url: "https://github.com/liam-i/FlyHUD.git", from: "1.5.12")
],
targets: [
.target(
name: "MyTarget", dependencies: [
.product(name: "FlyHUD", package: "FlyHUD"), // Optional
.product(name: "FlyProgressHUD", package: "FlyHUD"), // Optional
.product(name: "FlyIndicatorHUD", package: "FlyHUD") // Optional
])
]
...using Xcode
If you are using Xcode, then you should:
- File > Swift Packages > Add Package Dependency
- Add
https://github.com/liam-i/FlyHUD.git
- Select "Up to Next Minor" with "1.5.12"
[!TIP] For detailed tutorials, see: Apple Docs
CocoaPods
If you're using CocoaPods, add this to your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
# Or use CND source
# source 'https://cdn.cocoapods.org/'
platform :ios, '12.0'
use_frameworks!
target 'MyApp' do
# Use the FlyHUD, FlyIndicatorHUD and FlyProgressHUD components.
pod 'FlyHUD', '~> 1.5.12'
# Or, just use the FlyHUD component.
pod 'FlyHUD', '~> 1.5.12', :subspecs => ['FlyHUD']
# Or, just use the FlyHUD and FlyIndicatorHUD components.
pod 'FlyHUD', '~> 1.5.12', :subspecs => ['FlyIndicatorHUD']
# Or, just use the FlyHUD and FlyProgressHUD components.
pod 'FlyHUD', '~> 1.5.12', :subspecs => ['FlyProgressHUD']
end
And run pod install
.
[!IMPORTANT]
CocoaPods 1.13.0 or newer is required.
Carthage
If you're using Carthage, add this to your Cartfile
:
github "liam-i/FlyHUD" ~> 1.5.12
And run carthage update --platform iOS --use-xcframeworks
.
Usage
Using HUD
in your application is very simple.
- Displays the status HUD of an indeterminate tasks:
let hud = HUD.show(to: view)
DispatchQueue.global().async {
// Do something...
DispatchQueue.main.async {
hud.hide()
}
}
- Displays a task's progress HUD:
let hud = HUD.show(to: view, mode: .progress(), label: "Loading")
Task.request { progress in
hud.progress = progress
} completion: {
hud.hide()
}
- Displays a text-only status HUD:
HUD.showStatus(to: view, label: "Wrong password")
- Displays a custom view's status HUD. e.g. a UIImageView:
HUD.showStatus(to: view, mode: .custom(UIImageView(image: UIImage(named: "Checkmark")?.withRenderingMode(.alwaysTemplate))), label: "Completed")
- Displays a custom view's status HUD. And the UIImageView is on the left:
HUD.showStatus(to: view, mode: .custom(UIImageView(image: UIImage(named: "warning"))), label: "You have an unfinished task.") {
$0.contentView.indicatorPosition = .leading
}
- Sets the animation that should be used when showing and hiding the HUD. E.g. style, duration, spring damping:
HUD.showStatus(to: view, using: .animation(.slideUpDown, damping: .default, duration: 0.3), label: "Wrong password")
- Enable keyboard layout guide to track the keyboard's position in your app’s layout:
HUD.showStatus(to: view, label: "You have a message.") {
$0.keyboardGuide = .center()
}
[!WARNING] HUD is a UI class and should therefore only be accessed on the main thread.
For more examples, including how to use the HUD with asynchronous operations such as URLSession, and how to customize the HUD style, take a look at the bundled example project. Extensive API documentation is available here.
To run the example project, first clone the repo, then cd
to the root directory and run pod install
. Then open HUD.xcworkspace in Xcode.
Documentation
The documentation for releases and main
are available here:
Why the name FlyHUD?
The name FlyHUD combines Fly
and HUD
and stands out for its simplicity and expressiveness. Fly
implies fast, efficient and flexible meaning, which is consistent with the real-time and immediacy of HUD
. Overall, FlyHUD expresses the ability of HUD
to present information and data quickly and efficiently.
Credits and thanks
- Thanks a lot to Jonathan George for building MBProgressHUD - all ideas in here and many implementation details were provided by his library.
- Thanks a lot to Vinh Nguyen for building NVActivityIndicatorView - many implementation details of the loading animations here are provided by his library.
- Thanks a lot to Related Code for building ProgressHUD - many implementation details of the loading animations here are provided by his library.
License
FlyHUD is available under the MIT license. See the LICENSE file for more info.