Swift-based HUD for showing loading spinner, progress or any image with a status.
The library is compatible with Swift 5.2 and iOS 13+
See FMProgressHUD-Demo for demo
HUD should show either one of the following combinations:
- indefinite loading spinner
- indefinite loading spinner with status
- progress loading spinner
- progress loading spinner with status
- image
- image with status
-
In Project Settings -> Swift Package Manager, click +, paste the github URL and select the version settings
-
Added packages are shown under Project Settings -> Swift Package Manager and in Source Control Navigator
-
Add
import FMProgressHUD
to files where you want to use the HUD
- Copy over the
FMProgressHUD
folder into your project - Add
import FMProgressHUD
FMProgressHUD
is a singleton class that provides static properties to configure the HUD and static methods to show the HUD. No initialisation is required.
// show indefinite loading spinner
FMProgressHUD.show()
// show progress loading spinner
// note that progess ranges from 0 to 1
FMProgressHUD.show(progress: 0.1, status: "Loading...")
// show info
FMProgressHUD.showInfo(status: "Information")
// show success
FMProgressHUD.showSuccess(status: "Success")
// show error
FMProgressHUD.showError(status: "Error")
// show an image with a status
let image = UIImage(systemName: "person.fill.checkmark")!
FMProgressHUD.show(image: image, status: "Contact added")
// dismiss the HUD
FMProgressHUD.dismiss()
FMProgressHUD static methods:
static func show(status: String? = nil)
static func showInfo(status: String? = nil)
static func showSuccess(status: String? = nil)
static func showError(status: String? = nil)
static func show(image: UIImage, status: String? = nil)
The following fields can be customised:
var animationType = FMProgressHUDAnimationType.flat // Can be: flat, native (iOS native UIActicityIndicatorView)
var maskType = FMProgressHUDMaskType.clear // Can be: clear, black, or custom
var hudStyle = FMProgressHUDStyle.light // Can be: light, dark, or custom
var backgroundColor = UIColor.clear
var hudForegroundColor = UIColor.black
var hudBackgroundColor = UIColor.white
var hudViewCustomBlurEffect: UIBlurEffect?
var allowUserInteraction = true
var fadeInAnimationDuration: TimeInterval = 0.15
var fadeOutAnimationDuration: TimeInterval = 0.15
var imageSize = CGSize(width: 28, height: 28)
var cornerRadius: CGFloat = 14
var ringThickness: CGFloat = 2
var labelFontSize: CGFloat = 15
You can set loading animation using FMProgressHUD.animationType
You can set mask using FMProgressHUD.maskType
For custom masks color, set FMProgressHUD.backgroundColor
You can set style using FMProgressHUD.hudStyle
If .custom
is selected, you can customise it by setting: FMProgressHUD.hudViewCustomBlurEffect
, FMProgressHUD.hudBackgroundColor
, and FMProgressHUD.hudForegroundColor