A clean and lightweight progress HUD based on SVProgressHUD, converted to Swift with the help of Swiftify.

Last update: Jun 24, 2022

IHProgressHUD

IHProgressHUD is a clean and easy-to-use HUD meant to display the progress of an ongoing task on iOS and tvOS. IHProgressHUD is based on SVProgressHUD and ported to Swift with the help of Swiftify, with improvements like added thread safety and not using complier flag for use in iOS App Extension.

IHProgressHUD

Demo

Try IHProgressHUD on Appetize.io.

Installation

From CocoaPods

CocoaPods is a dependency manager for Objective-C and Swift, which automates and simplifies the process of using 3rd-party libraries like IHProgressHUD in your projects. First, add the following line to your Podfile:

pod 'IHProgressHUD'

If you want to use the latest features of IHProgressHUD use normal external source dependencies.

pod 'IHProgressHUD', :git => 'https://github.com/Swiftify-Corp/IHProgressHUD.git'

This pulls from the master branch directly.

Second, install IHProgressHUD into your project:

pod install

From SwiftPM

Under your project from the File menu, go to Swift Packages and select Add Package Dependency

Enter the address of the repository for the package you wish to add.

After you hit Next, you’ll see another form. From here you’re able to specify which version, branch, or commit hash you’d like to add as a dependency.

After you click Next, Xcode will fetch the dependency. In this final window, make sure the package you want to add is checked and the target you wish to add it to is selected from the dropdown.

After you click Finish, you’ll see that the added package is now listed in the navigator under a new section titled Swift Package Dependencies.

To Remove the package

If you need to remove a SwiftPM package from your project, you can select the project at the top of the navigator, then look for the tab titled Swift Packages. (It’s next to Build Settings).

Usage

IHProgressHUD is created as a singleton (i.e. it doesn't need to be explicitly allocated and instantiated; you directly call IHProgressHUD.method()). It can be accessed from even the background thread.

Use IHProgressHUD wisely! Only use it if you absolutely need to perform a task before taking the user forward. Bad use case examples: pull to refresh, infinite scrolling, sending message.

Using IHProgressHUD in your app will usually look as simple as this (using Grand Central Dispatch):

IHProgressHUD.show()
DispatchQueue.global(qos: .default).async(execute: {
// time-consuming task
IHProgressHUD.dismiss()
})

Showing the HUD

You can show the status of indeterminate tasks using one of the following:

class func show()
class func show(withStatus status: String?)

If you'd like the HUD to reflect the progress of a task, use one of these:

class func show(progress: CGFloat)
class func show(progress: CGFloat, status: String?)

Dismissing the HUD

The HUD can be dismissed using:

class func dismiss()
class func dismissWithCompletion(_ completion: (() -> Void)?)
class func dismissWithDelay(_ delay: TimeInterval)
class func dismissWithDelay(_ delay: TimeInterval, completion: (() -> Void)?)

If you'd like to stack HUDs, you can balance out every show call using:

class func popActivity()

The HUD will get dismissed once the popActivity calls will match the number of show calls.

Or show a confirmation glyph before before getting dismissed a little bit later. The display time depends on minimumDismissTimeInterval and the length of the given string.

class func showInfowithStatus(_ status: String?)
class func showSuccesswithStatus(_ status: String?)
class func showError(withStatus status: String?)
class func showImage(_ image: UIImage, status: String?)

Customization

IHProgressHUD can be customized via the following methods:

class func set(defaultStyle style: IHProgressHUDStyle) // default is IHProgressHUDStyle.light

class func set(defaultMaskType maskType: IHProgressHUDMaskType) // default is IHProgressHUDMaskType.none

class func set(defaultAnimationType type: IHProgressHUDAnimationType) // default is IHProgressHUDAnimationType.flat

class func set(containerView: UIView?) // default is window level

class func set(minimumSize: CGSize) // default is CGSize.zero, can be used to avoid resizing

class func set(ringThickness: CGFloat) // default is 2 pt

class func set(ringRadius : CGFloat) // default is 18 pt

class func setRing(noTextRingRadius radius: CGFloat) // default is 24 pt

class func set(cornerRadius: CGFloat) // default is 14 pt

class func set(borderColor color : UIColor) // default is nil

class func set(borderWidth width: CGFloat)  // default is 0

class func set(font: UIFont) // default is UIFont.preferredFont(forTextStyle: .subheadline)

class func set(foregroundColor color: UIColor) // default is nil

class func set(backgroundColor color: UIColor) // default is nil

class func set(backgroundLayerColor color: UIColor) // default is UIColor.init(white: 0, alpha: 0.4), only used for IHProgressHUDMaskType.custom

class func set(imageViewSize size: CGSize) // default is 28x28 pt

class func set(shouldTintImages: Bool) // default is true

class func set(infoImage image: UIImage) // default is the bundled info image provided by Freepik

class func setSuccessImage(successImage image: UIImage) // default is bundled success image from Freepik

class func setErrorImage(errorImage image: UIImage) // default is bundled error image from Freepik

class func set(viewForExtension view: UIView) // default is nil, only used for App Extension

class func set(graceTimeInterval interval: TimeInterval) // default is 5.0 seconds

class func set(maximumDismissTimeInterval interval: TimeInterval) // default is TimeInterval(CGFloat.infinity)

class func setFadeInAnimationDuration(fadeInAnimationDuration duration: TimeInterval) // default is 0.15 seconds

class func setFadeOutAnimationDuration(fadeOutAnimationDuration duration: TimeInterval) // default is 0.15 seconds

class func setMaxSupportedWindowLevel(maxSupportedWindowLevel windowLevel: UIWindow.Level) // default is UIWindowLevelNormal

class func setHapticsEnabled(hapticsEnabled: Bool) // default is NO

Hint

As standard IHProgressHUD offers two preconfigured styles:

  • IHProgressHUDStyle.light: White background with black spinner and text
  • IHProgressHUDStyle.dark: Black background with white spinner and text

If you want to use custom colors use setForegroundColor and setBackgroundColor:. These implicitly set the HUD's style to IHProgressHUDStyle.custom.

Haptic Feedback

For users with newer devices (starting with the iPhone 7), IHProgressHUD can automatically trigger haptic feedback depending on which HUD is being displayed. The feedback maps as follows:

  • showSuccessWithStatus: <-> UINotificationFeedbackTypeSuccess
  • showInfoWithStatus: <-> UINotificationFeedbackTypeWarning
  • showErrorWithStatus: <-> UINotificationFeedbackTypeError

To enable this functionality, use setHapticsEnabled:.

Users with devices prior to iPhone 7 will have no change in functionality.

Notifications

IHProgressHUD posts four notifications via NSNotificationCenter in response to being shown/dismissed:

  • NotificationName.IHProgressHUDWillAppear when the show animation starts
  • NotificationName.IHProgressHUDDidAppear when the show animation completes
  • NotificationName.IHProgressHUDDidDisappear when the dismiss animation starts
  • NotificationName.IHProgressHUDDidAppear when the dismiss animation completes

Each notification passes a userInfo dictionary holding the HUD's status string (if any), retrievable via [NotificationName.IHProgressHUDStatusUserInfoKey.getNotificationName()].

IHProgressHUD also posts IHProgressHUDDidReceiveTouchEvent when users touch on the overall screen or IHProgressHUDDidTouchDownInside when a user touches on the HUD directly. For this notifications userInfo is not passed but the object parameter contains the UIEvent that related to the touch.

App Extensions

When using IHProgressHUD in an App Extension, use the class func set(viewForExtension view: UIView) there is no need to set any complier flag.

Contributing to this project

If you have feature requests or bug reports, feel free to help out by sending pull requests or by creating new issues. Please take a moment to review the guidelines written by Nicolas Gallagher:

License

IHProgressHUD is distributed under the terms and conditions of the MIT license. The success, error and info icons are made by Freepik from Flaticon and are licensed under Creative Commons BY 3.0.

Credits

IHProgressHUD is brought to you by Md Ibrahim Hassan and contributors to the project. If you're using IHProgressHUD in your project, attribution would be very appreciated. This project is converted with the help of Swiftify. The conversion process can be found here.

GitHub

https://github.com/Swiftify-Corp/IHProgressHUD
Comments
  • 1. Unexpected duplicate tasks - iOS 13 - Xcode 11

    Hi,

    I wanted to update our apps to iOS 13 and archiving it fails with errors like:

    Unexpected duplicate tasks:

    1. Target 'IHProgressHUD' (project 'Pods') has copy command from '.../Pods/IHProgressHUD/IHProgressHUD/Classes/IHProgressHUD.bundle/[email protected]' to '.../Library/Developer/Xcode/DerivedData/Animest-bpcsmwfbgjyhfvebytrdskxkoder/Build/Intermediates.noindex/ArchiveIntermediates/Animest Dev/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/IHProgressHUD.framework/[email protected]'
    2. Target 'IHProgressHUD' (project 'Pods') has copy command from '.../Pods/IHProgressHUD/IHProgressHUD/Classes/IHProgressHUD.bundle/[email protected]' to '.../Library/Developer/Xcode/DerivedData/Animest-bpcsmwfbgjyhfvebytrdskxkoder/Build/Intermediates.noindex/ArchiveIntermediates/Animest Dev/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/IHProgressHUD.framework/[email protected]'

    The fix is simple and can be done easily. Just untick the target membership box for the items, and tick it back on.

    If you can fix this fast so I can start my pipelines for release today, I would appreciate it very much.

    PS: more info link, https://stackoverflow.com/questions/52384152/xcode-10-unexpected-duplicate-task-copyplistfile

    Reviewed by sbrighiu at 2019-09-22 16:34
  • 2. Testing on iPhone Xs Device causes a "Main Thread Checker" exception.

    The moment I execute IHProgressHUD.show(withStatus: "")

    I get a:

    Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
    PID: 9428, TID: 3268605, Thread name: com.apple.CoreMotion.MotionThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
    

    https://developer.apple.com/documentation/code_diagnostics/main_thread_checker fyi: https://github.com/SVProgressHUD/SVProgressHUD/pull/822

    Reviewed by sedwo at 2019-02-01 17:58
  • 3. Crash when initializing IHProgressHud - Unexpectedly found nil while unwrapping an Optional value

    For example when I'm trying to create IHProgressHud in viewDidLoad() simply like this:

    DispatchQueue.global(qos: .utility).async { IHProgressHUD.show() }

    Then the app crashes with the following error:

    Fatal error: Unexpectedly found nil while unwrapping an Optional value: file /Users/////Pods/IHProgressHUD/IHProgressHUD/Classes/IHProgressHUD.swift, line 369

    The iOS deployment target is 13.0 and Swift 5 language.

    Reviewed by goransleko at 2020-07-27 10:10
  • 4. Fatal error: Unexpectedly found nil while unwrapping an Optional value

    let window : UIWindow = appDelegate.window! { In new xcode 11 projects appDelegate.window == nil because of using of scenes. Stop unwrap optionals via this incorrect way please. It is not the single project which has this issue

    Reviewed by Gargo at 2020-03-08 16:05
  • 5. Main Thread Checker

    If I drop the classes to the project without cocoapods,Main Thread Checker interrupted the app when It was ran "IHProgressHUD.show()"

    it was caused at "updateMotionEffectForOrientation(orientation)"

    屏幕快照 2019-12-11 上午9 58 34

    animation issue IMG_4501

    Reviewed by sprother at 2019-12-11 02:01
  • 6. support as a static framework

    My project use new feature of cocoapod 1.5, static framework. So the framework assets becomes as one part of main application.

    when using as a static framework, assets will load failed. I will collect more detail soon.

    Reviewed by Jenus at 2019-01-31 08:10
  • 7. Can you please fix the completion handler for dismissWithDelay?

    When completion is used inside completionBlock, the completion parameter is nil, making so that dismissWithDelay trailing completion block is not called

    Reviewed by sbrighiu at 2020-12-02 16:15
  • 8. Unable to install from git repo

    With following in pod file pod 'IHProgressHUD', :git => 'https://github.com/Swiftify-Corp/IHProgressHUD.git'

    Getting: Installing IHProgressHUD 0.1.5

    [!] Error installing IHProgressHUD [!] /usr/bin/git clone https://github.com/Swiftify-Corp/IHProgressHUD.git /var/folders/md/dwx6kp3x3vg0203p3nz_gshc0000gp/T/d20201120-9836-x1d7il --template= --single-branch --depth 1 --branch 0.1.5

    Cloning into '/var/folders/md/dwx6kp3x3vg0203p3nz_gshc0000gp/T/d20201120-9836-x1d7il'... warning: Could not find remote branch 0.1.5 to clone. fatal: Remote branch 0.1.5 not found in upstream origin

    Reviewed by aliawais at 2020-11-19 23:38
  • 9. Type 'Bundle' has no member 'module'

    App was compiling without any issues, after running 'pod install' using its master branch started having compilation error "Type 'Bundle' has no member 'module'" on two files:

    • IHProgressHUD.swift
    • IndefiniteAnimatedView.swft

    In pod file I have pod 'IHProgressHUD', :git => 'https://github.com/Swiftify-Corp/IHProgressHUD.git'

    Also tried in a fresh app, same issue. But if I use pod 'IHProgressHUD' then it works fine.

    How to solve the issue? I am using Xcode 11.7

    Reviewed by aliawais at 2020-10-21 02:57
  • 10. Add support for custom foreground image color and custom blur effects

    From what I understand, the big conversion to Swift of SVProgressHUD was done around November 2018. I was thinking to go through new additions to SVProgressHUD in chronological order and port them over to IHProgressHUD. Here I started with this commit from Jan 23, 2019 which adds the option to have a custom blur effect even with a custom text or image color and adds the option to set a custom color only for image or loading indicator ring while keeping the default text color inside the progress hud.

    I successfully tested it manually. It would be nice to add options to test the above in the Example app but I noticed that UI is all done with individual auto layout constraints for each view. It would be much easier to use stack views where we could easily drop in new controls as more features are added. That feels like a bigger separate PR and I wanted to start small.

    Reviewed by massimobio at 2020-06-27 18:47
  • 11. Create a tag for the latest master

    I want to use the master code as a dependency in a pod but I'm unable to do so since there is no tag created for the same. Can we publish a new release from master?

    Reviewed by vinitam at 2020-04-28 10:20
  • 12. Reimplement indefinite animated view with a gradient

    These changes are based on the changes in SVProgressHUD in this commit on Feb 12, 2019.

    Reimplement indefinite animated view to not use an image as mask but instead just use a gradient. Also, use round lineJoin for nicer rounded shape.

    Reviewed by massimobio at 2020-07-15 04:37
  • 13. Please update to use latest SVProgressHUD code

    Thanks for creating and maintaining this great project!

    Since many bugs were fixed since the code was ported, would it be possible to update this to use the latest SVProgressHUD code?

    Reviewed by zacwolfe at 2019-09-12 18:23
IOS HUD Swift Library

JHProgressHUD JHProgressHUD is an iOS class written in Swift to display a translucent HUD with an indicator and/or labels while work is being done in

Feb 27, 2021
This is a beauful hud view for iPhone & iPad
This is a beauful hud view for iPhone & iPad

WSProgressHUD This is a beauful hud view for iPhone & iPad Usage To Download the project. Run the WSProgressHUD.xcodeproj in the demo directory. [

Jun 19, 2022
Simple HUD.
Simple HUD.

VHUD Simple HUD. VHUD is inspired by PKHUD. Example Show import VHUD func example() { var content = VHUDContent(.loop(3.0)) content.loadingText =

Jan 24, 2021
Completely customizable progress based loaders drawn using custom CGPaths written in Swift
Completely customizable progress based loaders drawn using custom CGPaths written in Swift

FillableLoaders Completely customizable progress based loaders drawn using custom CGPaths written in Swift Waves Plain Spike Rounded Demo: Changelog:

Jun 27, 2022
Step-by-step progress view with labels and shapes. A good replacement for UIActivityIndicatorView and UIProgressView.
Step-by-step progress view with labels and shapes. A good replacement for UIActivityIndicatorView and UIProgressView.

StepProgressView Step-by-step progress view with labels and shapes. A good replacement for UIActivityIndicatorView and UIProgressView. Usage let progr

Jun 11, 2022
UIProgressView replacement with an highly and fully customizable animated progress bar in pure Core Graphics
UIProgressView replacement with an highly and fully customizable animated progress bar in pure Core Graphics

The YLProgressBar is an UIProgressView replacement with a highly and fully customizable animated progress bar in pure Core Graphics. It has been imple

Jun 2, 2022
Simple and powerful animated progress bar with dots

Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements iOS 8.0+ Swift 3.0+ Installatio

Apr 1, 2021
A simple animated progress bar in Swift
A simple animated progress bar in Swift

DSGradientProgressView Introduction DSGradientProgressView is a simple and customizable animated progress bar written in Swift. Inspired by GradientPr

May 16, 2022
Flexible Stepped Progress Bar for IOS
Flexible Stepped Progress Bar for IOS

FlexibleSteppedProgressBar This is a stepped progress bar for IOS. The base code is derived from ABSteppedProgressBar. Most of the design is customisa

Jun 23, 2022
📊 A customizable gradient progress bar (UIProgressView).
📊 A customizable gradient progress bar (UIProgressView).

GradientProgressBar A customizable gradient progress bar (UIProgressView). Inspired by iOS 7 Progress Bar from Codepen. Example To run the example pro

Jun 7, 2022
💈 Retro looking progress bar straight from the 90s
💈 Retro looking progress bar straight from the 90s

Description Do you miss the 90s? We know you do. Dial-up internet, flickering screens, brightly colored websites and, of course, this annoyingly slow

Apr 23, 2022
Material Linear Progress Bar for your iOS apps
Material Linear Progress Bar for your iOS apps

LinearProgressBar Material Linear Progress Bar for your iOS apps Installation Carthage: github "Recouse/LinearProgressBar" CocoaPods: Add this to you

Jun 24, 2022
A lightweight and awesome loading Activity Indicator for your iOS app.
 A lightweight and awesome loading Activity Indicator for your iOS app.

BPCircleActivityIndicator BPCircleActivityIndicator is a clean and easy-to-use Activity Indicator meant to display the progress of an ongoing task on

Oct 26, 2020
A beautiful activity indicator and modal alert written in Swift (originally developed for my app DoodleDoodle) Using blur effects, translucency, flat and bold design - all iOS 8 latest and greatest
A beautiful activity indicator and modal alert written in Swift (originally developed for my app DoodleDoodle) Using blur effects, translucency, flat and bold design - all iOS 8 latest and greatest

SwiftSpinner SwiftSpinner is an extra beautiful activity indicator with plain and bold style. It uses dynamic blur and translucency to overlay the cur

Jun 18, 2022
A view class for iOS that makes uploading easy and beautiful.
A view class for iOS that makes uploading easy and beautiful.

SVUploader A view class for iOS that makes uploading easy and beautiful. Demo SVUploader is fully customizable - check out 2 demos. Installation Just

Apr 18, 2022
A simple and awesome loading Activity Indicator(with block moving animation) for your iOS app.
A simple and awesome loading Activity Indicator(with block moving animation) for your iOS app.

BPBlockActivityIndicator BPBlockActivityIndicator is a clean and easy-to-use Activity Indicator meant to display the progress of an ongoing task on iO

Nov 6, 2021
☠️ An elegant way to show users that something is happening and also prepare them to which contents they are awaiting
☠️ An elegant way to show users that something is happening and also prepare them to which contents they are awaiting

Features • Guides • Installation • Usage • Miscellaneous • Contributing ?? README is available in other languages: ???? . ???? . ???? . ???? . ???? To

Jun 26, 2022
StatusBarOverlay will automatically show a "No Internet Connection" bar when your app loses connection, and hide it again
StatusBarOverlay will automatically show a

StatusBarOverlay will automatically show a "No Internet Connection" bar when your app loses connection, and hide it again. It supports apps which hide the status bar and The Notch

May 29, 2022
A metaball loading written in Swift.

DBMetaballLoading Synopsis A metaball loading written in Swift. Special thanks to dodola's MetaballLoading, which is an android project. The animation

Apr 14, 2020