A beautiful and easy-to-use progress HUD for your iOS.

Overview

日本語

Version License Platform Download Carthage compatible CI Status

KRProgressHUD is a beautiful and easy-to-use progress HUD for your iOS written by Swift.

KRActivityIndicatorView is used for loading view.

Features

  • Round indicator
  • Indicator color can be customized

Requirements

  • iOS 9.0+
  • Xcode 12.0+
  • Swift 5.3+

DEMO

To run the example project, clone the repo, and open KRProgressHUDDemo.xcodeproj from the DEMO directory.

or appetize.io

Installation

KRProgressHUD is available through CocoaPods and Carthage. To install it, simply add the following line to your Podfile or Cartfile:

# CocoaPods
pod "KRProgressHUD"
# Carthage
github "Krimpedance/KRProgressHUD"

Usage

(see sample Xcode project in /Demo)

Caution :

Only use it if you absolutely need to perform a task before taking the user forward.

If you want to use it with other cases (ex. pull to refresh), I suggest using KRActivityIndicatorView.

KRProgressHUD is created as a singleton.

At first, import KRProgressHUD in your swift file.

Show simple HUD :

KRProgressHUD.show()

DispatchQueue.main.asyncAfter(deadline: .now()+1) {
   KRProgressHUD.dismiss()
}

Showing the HUD

class func show(withMessage message:String? = nil, completion: CompleteHandler? = nil)

// Example
KRProgressHUD.show()
KRProgressHUD.show(withMessage: "Loading...")
KRProgressHUD.show(withMessage: "Loading...") {
   print("Complete handler")
}

Show on ViewController

If you want to show HUD on a view controller, set at showOn().

(This is applied only once.)

  KRProgressHUD.showOn(viewController).show()

Show a confirmation glyph before getting dismissed a little bit later. (The display time is 1 sec in default. You can change the timing.)

class func showSuccess()
class func showInfo()
class func showWarning()
class func showError()
class func showImage() // This can set custom image. (Max size is 50x50)

Show the HUD (only message)

public class func showMessage(_ message: String)

// Example
KRProgressHUD.showMessage("Completed! \n Let's start!")

Update the HUD's message

The HUD can update message.

class func update(message: String)

// Example
KRProgressHUD.update(message: "20%")

Dismissing the HUD

The HUD can be dismissed using:

class func dismiss(_ completion: CompleteHandler? = nil)

Customization

KRProgressHUD.appearance() can set default styles.

class KRProgressHUDAppearance {
    /// Default style.
    public var style = KRProgressHUDStyle.white
    /// Default mask type.
    public var maskType = KRProgressHUDMaskType.black
    /// Default KRActivityIndicatorView colors
    public var activityIndicatorColors = [UIColor]([.black, .lightGray])
    /// Default message label font.
    public var font = UIFont.systemFont(ofSize: 13)
    /// Default HUD center offset of y axis.
    public var viewOffset = CGFloat(0.0)
    /// Default duration to show HUD.
    public var duration = Double(1.0)
}

When you'd like to make styles reflected only in specific situation, use following methods.

@discardableResult public class func set(style: KRProgressHUDStyle) -> KRProgressHUD.Type
@discardableResult public class func set(maskType: KRProgressHUDMaskType) -> KRProgressHUD.Type
@discardableResult public class func set(activityIndicatorViewColors colors: [UIColor]) -> KRProgressHUD.Type
@discardableResult public class func set(font: UIFont) -> KRProgressHUD.Type
@discardableResult public class func set(viewOffset offset: CGFloat) -> KRProgressHUD.Type
@discardableResult public class func set(duration: Double) -> KRProgressHUD.Type


// Example
KRProgressHUD
   .set(style: .custom(background: .blue, text: .white, icon: nil))
   .set(maskType: .white)
   .show()

These set() setting can be reset by

@discardableResult public class func resetStyles() -> KRProgressHUD.Type

Contributing to this project

I'm seeking bug reports and feature requests.

Release Note

  • 3.4.7 :

    • Support for iOS 11 and below
  • 3.4.6 :

    • Update for Xcode 12

License

KRProgressHUD is available under the MIT license.

See the LICENSE file for more info.

Comments
  • Progress Hud would not show second time in VC

    Progress Hud would not show second time in VC

    Hello, I'm facing an issue with progress hud, it would run second time in any VC and hang the app on a physical device. but seems fine in the simulator.

    Simulator: iPhone 7 iOS 13 Device: iPhone 7 iOS 13

    opened by SohaibSiddique 10
  • ActivityIndicator not displaying

    ActivityIndicator not displaying

    I use KRProgressHUD.show(withMessage: "Loading...") to show a loading indicator, but occasionally the loading indicator (spinner) is not displayed .Ref image. Reproduced in iOS 10 devices .

    opened by sivishaatrehts 8
  • After showing loader other Success or Error view not getting display in Same VC:  Xcode 11

    After showing loader other Success or Error view not getting display in Same VC: Xcode 11

    Hi, on api call I'm showing loader and on success I'm showing Success view but its not getting display, I tried too many times. Xcode version - 11 pod version - 3.4.2

    opened by bhushanbafana 7
  • Not compile with Xcode 10

    Not compile with Xcode 10

    Not compile with Xcode 10 Swift 4.2 DeplymentTarget iOS 10.0 Cocoapods 1.5.3

    Errors: /Users/.../Pods/KRActivityIndicatorView/KRActivityIndicatorView/Classes/KRActivityIndicatorView.swift:111:62: 'kCAMediaTimingFunctionLinear' has been renamed to 'CAMediaTimingFunctionName.linear' /QuartzCore.kCAMediaTimingFunctionLinear:3:12: 'kCAMediaTimingFunctionLinear' was obsoleted in Swift 3

    /Users/.../Pods/KRActivityIndicatorView/KRActivityIndicatorView/Classes/KRActivityIndicatorView.swift:114:28: 'kCAFillModeForwards' has been renamed to 'CAMediaTimingFillMode.forwards' /QuartzCore.kCAFillModeForwards:3:12: 'kCAFillModeForwards' was obsoleted in Swift 3

    opened by clasik 6
  • App crash while keyboard is open

    App crash while keyboard is open

    Hi, fist of all thank you very much for KRActivityIndicator. it's work fine and very nice activity indicator. but while keyboard is open and show indicator, app is going crash.

    Thanks Jaymin Patel.

    opened by jayminiphonedev 6
  • In slow internet connection, the loader is not visible.

    In slow internet connection, the loader is not visible.

    I tried the KTProgressHUD with good internet connection and slow internet connection. And I'm putting the loader before making the API call. And in good internet connection, the loader is showing perfectly. But in low internet connection, the screen gets freezes but loader is not showing. Can you please help me this?

    opened by hilajqinnovation 5
  • EXC_BAD_ACCESS on call from a controller inside a UITabBarController's

    EXC_BAD_ACCESS on call from a controller inside a UITabBarController's "More" menu item

    I have a UITabBarController with more than 5 controllers inside it, which in result puts some of them under the special "More" menu item: photo_2018-01-23_10-53-54

    And if one of these controllers hidden under "More" calls for example KRProgressHUD.show(withMessage: "test") the app will crash with EXC_BAD_ACCESS: screen shot 2018-01-23 at 10 36 48

    While controllers outside of "More" work as expected.

    Tested on the iPhone 6 with iOS 11.2.2 KRProgressHUD version: 3.2.0

    opened by gim- 5
  • Spinner stuck if dismissed immediately

    Spinner stuck if dismissed immediately

    Hello,

    Thank you for your work on this pod :)

    I'm currently using it to show that the application is calling a REST server so I usually begin() the spinner and when I get the reply from the server I dismiss() it.

    However, I have some specific situations where the REST call can be avoided and thus, what I end up doing is begin() the spinner and, a bit down the code, I dismiss it.

    What ends up happening is that the spinner goes away but the white box where it spins (and the whole dark layer) don't disappear.

    Any idea is this is a bug or if I'm doing something incorrectly.

    (ultimately I could devise some logic to stop showing the spinner in the first place but I would like to avoid that, if possible).

    Thank you1

    opened by luismachado 5
  • Only fullscreen?

    Only fullscreen?

    There is only one problem with your library. What if I just want to lock a specific ViewController with the ProgressHUD? E.g.: If I have a TabBarController that I can navigate through the tabs. Currently your library only supports showing in fullscreen mode, locking all the windows bellow it. Do you think that supporting presentation in a ViewController based root would be a good idea? If yes, I'm thinking about creating a pull request. :)

    opened by andersonlucasg3 4
  • Change view's center?

    Change view's center?

    After some digging through your code, I found that you have a sharedView() class func, but somehow i cannot call it by KRProgressHUD.sharedView(). Therefore, I don't see any ways to move the view.

    opened by urianawu 4
  • not showing HUD when using with

    not showing HUD when using with "SwiftPasscodeLock" like library.

    Hi, When I using library 'SwiftPasscodeLock'(I take passcode lock presenter from there) HUD is not showing. Can you help me figure out why?

    My AppDelegate where I have PinCodeLockPresenter class.

    import UIKit
    import Siren
    import IQKeyboardManagerSwift
    import KRProgressHUD
    
    @UIApplicationMain
    class AppDelegate: UIResponder, UIApplicationDelegate {
    
        var window: UIWindow?
        
        lazy var  pincodePresenter: PinCodeLockPresenter = {
            let presenter = PinCodeLockPresenter(mainWindow: self.window)
            return presenter
        }()
        
        var lastTimeAttemptToServer :TimeInterval!
        var isEnterWithLoginPasswordPressed: Bool = false
    
        func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
            
            
            IQKeyboardManager.shared.enable = true
            
            IQKeyboardManager.shared.toolbarDoneBarButtonItemText = "Готово ✔︎"
    
            let tabBarAppearance = UITabBar.appearance()
            
            tabBarAppearance.tintColor = UIColor(name: "green")
    
            let siren = Siren.shared
            
            siren.alertMessaging = SirenAlertMessaging(updateTitle: "Update",
                                                       updateMessage: "Update",
                                                       updateButtonMessage: "Обновить",
                                                       nextTimeButtonMessage: "Потом",
                                                       skipVersionButtonMessage: "Не хочу")
            
            siren.checkVersion(checkType: .immediately)
            
            KRProgressHUD.appearance().style = .black
            KRProgressHUD.appearance().activityIndicatorStyle = .gradationColor(head: UIColor(name: "green")!, tail: UIColor.orange)
            KRProgressHUD.appearance().maskType = .white
            KRProgressHUD.appearance().deadlineTime = Double(1.0)
            
            return true
        }
    
        func applicationWillResignActive(_ application: UIApplication) {
            print("applicationWillResignActive")
        }
    
        func applicationDidEnterBackground(_ application: UIApplication) {
            print("applicationDidEnterBackground")
            
            if UserLoginStuff.getPin() != nil {
                print("pin not null")
                pincodePresenter.presentPinCodeLock()
            }
        }
    
        func applicationWillEnterForeground(_ application: UIApplication) {
            print("applicationWillEnterForeground")
            if lastTimeAttemptToServer != nil {
                
                let secondsFromLastAttemptToServer = CFAbsoluteTimeGetCurrent() - lastTimeAttemptToServer
                
                print(secondsFromLastAttemptToServer)
                
                if secondsFromLastAttemptToServer >= 180 {
                    UIApplication.shared.keyWindow?.rootViewController?.dismiss(animated: true, completion: nil)
                }
            }
        }
    
        func applicationDidBecomeActive(_ application: UIApplication) {
            print("applicationDidBecomeActive")
        }
    
        func applicationWillTerminate(_ application: UIApplication) {
            print("applicationWillTerminate")
    
        }
        
    }
    
    
    extension UIApplication {
            class func topVC(base: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController? {
                if let nav = base as? UINavigationController {
                    return topVC(base: nav.visibleViewController)
                }
                if let tab = base as? UITabBarController {
                    if let selected = tab.selectedViewController {
                        return topVC(base: selected)
                    }
                }
                if let presented = base?.presentedViewController {
                    return topVC(base: presented)
                }
                //print(base)
                return base
            }
    }
    
    
    open class PinCodeLockPresenter {
        fileprivate var mainWindow: UIWindow?
        
        fileprivate lazy var pincodelockWindow: UIWindow = {
            let window = UIWindow(frame: UIScreen.main.bounds)
            
            window.windowLevel = 0
            window.makeKeyAndVisible()
            
            return window
        }()
        
        open var isPinCodePresented = false
        let pincodelockVC: BlurPinCodeLockVC
        
        init(mainWindow window: UIWindow?, viewContr: BlurPinCodeLockVC) {
            mainWindow = window
            mainWindow?.windowLevel = 1
            
            pincodelockVC = viewContr
        }
        
        public convenience init(mainWindow window: UIWindow?) {
            let storyboard = UIStoryboard(name: "Main", bundle: nil)
            let pincodelockVC = storyboard.instantiateViewController(withIdentifier: "BlurPasswordLoginViewController") as! BlurPinCodeLockVC
            
            self.init(mainWindow: window, viewContr: pincodelockVC)
        }
        
        open func presentPinCodeLock() {
            guard !isPinCodePresented else {return}
            
            isPinCodePresented = true
            print("isPinCodePresented = true")
            pincodelockWindow.windowLevel = 2
            pincodelockWindow.isHidden = false
            
            mainWindow?.windowLevel = 1
            mainWindow?.endEditing(true)
            
            let storyboard = UIStoryboard(name: "Main", bundle: nil)
            let pincodelockVC = storyboard.instantiateViewController(withIdentifier: "BlurPasswordLoginViewController") as! BlurPinCodeLockVC
            
            let userDismissPinVCCallback = pincodelockVC.calbackForDismiss
            
            pincodelockVC.calbackForDismiss = { [weak self]  in
                userDismissPinVCCallback()
                self?.dismissPincodeLock()
                
                if (UIApplication.shared.delegate as! AppDelegate).isEnterWithLoginPasswordPressed {
                    //print("hier0")
                    UIApplication.shared.keyWindow?.rootViewController?.dismiss(animated: false, completion: nil)
                }
                
                if let vc = UIApplication.topVC() as? LoginViewController {
                    //print("hier")
                    if !(UIApplication.shared.delegate as! AppDelegate).isEnterWithLoginPasswordPressed {
                        if let loginPass = UserLoginStuff.getLoginPasswordArray() {
                            //print("hier 2")
                            vc.startSessionAndSignIn(login: loginPass.first, password: loginPass.last)
                        }
                    }
                }
            }
            
            pincodelockWindow.rootViewController = pincodelockVC
        }
        
        open func dismissPincodeLock(animated: Bool = true) {
        
            isPinCodePresented = false
            mainWindow?.windowLevel = 1
            mainWindow?.makeKeyAndVisible()
            
            if animated {
                animatePincodeLockDismissing()
            } else {
                pincodelockWindow.windowLevel = 0
                pincodelockWindow.rootViewController = nil
            }
        }
        
        internal func animatePincodeLockDismissing() {
            UIView.animate(
                withDuration: 0.5,
                delay: 0,
                usingSpringWithDamping: 1,
                initialSpringVelocity: 0,
                options: UIViewAnimationOptions(),
                animations: {[weak self] in
                    self?.pincodelockWindow.alpha = 0
                },
                completion: {[weak self] _ in
                    self?.pincodelockWindow.windowLevel = 0
                    self?.pincodelockWindow.rootViewController = nil
                    self?.pincodelockWindow.alpha = 1
                }
            )
        }
    }
    
    opened by NMaks07 3
  • KRProgressHUD.dismiss() sets rootViewController to KRProgressHUDViewController

    KRProgressHUD.dismiss() sets rootViewController to KRProgressHUDViewController

    Hi.

    When i dismiss KRProgressHUD the rootViewController is still set to KRProgressHUDViewController. Is there any work-around to inherit my old value before setting it? If I check the dismiss method this is done: if self.presentingViewController != nil { self.hudViewController.willMove(toParent: nil) self.hudViewController.view.removeFromSuperview() self.hudViewController.removeFromParent() self.presentingViewController = nil self.window.rootViewController = self.hudViewController }

    so at the end the rootViewController is set again to self.hudViewController.

    opened by SlavcoPetkovski 0
  • KRProgressHUD.dismiss() dismiss AlertView

    KRProgressHUD.dismiss() dismiss AlertView

    If some UIAlertView is added while ProgressHUD is loading. after that if we call KRProgressHUD.dismiss() than it will also dismiss the default UIAlertView

    opened by rizwan-ahmed 5
  • Not working with TabBarController.

    Not working with TabBarController.

    I have tab bar and for each view controller i have to show progress but it only work on first view controller . i am using KRProgressHUD.showOn(self).show() for each view controller but its not working.

    opened by jahnaviwisdom-zz 2
  • show message only once

    show message only once

    Hello I'm using this code KRProgressHUD.set(duration: 2).set(font: fontRegular(size: 14)).showInfo(withMessage: "Error")

    but only show message once and not working again

    opened by MansoorJafari9 16
Releases(3.4.4)
Owner
K.R.Impedance
K.R.Impedance
Customizable HUD for swift

HUD Customizable HUD. Requirements Installation Swift Package Manager The Swift Package Manager is a tool for automating the distribution of Swift cod

Horizontal Systems 1 Oct 6, 2022
Progress.swift ⌛ Add beautiful progress bars to your loops.

Progress.swift ⌛ Just wrap the SequenceType in your loop with the Progress SequenceType and you'll automatically get beautiful progress bars. Updating

Justus Kandzi 304 Dec 1, 2022
A clean and lightweight progress HUD based on SVProgressHUD, converted to Swift with the help of Swiftify.

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

Swiftify 202 Dec 22, 2022
TTProgressHUD is a light weight HUD written in SwiftUI meant to display the progress of an ongoing task on iOS.

TTProgressHUD TTProgressHUD is a light weight HUD written in SwiftUI meant to display the progress of an ongoing task on iOS. TTProgressHUD (left) was

Tobias Totzek 184 Dec 27, 2022
Simple Swift Progress HUD

MKProgress An iOS Simple Swift Progress HUD Requirements iOS 9.0+ Swift 3.0+ Xcode 8.0+ Installation MKProgress is only available via CocoaPods: pod '

Muhammad Kamran 143 Dec 23, 2022
Shawn Frank 2 Aug 31, 2022
(Animate CSS) animations for iOS. An easy to use library of iOS animations. As easy to use as an easy thing.

wobbly See Wobbly in action (examples) Add a drop of honey ?? to your project wobbly has a bunch of cool, fun, and easy to use iOS animations for you

Sagaya Abdulhafeez 150 Dec 23, 2021
(Animate CSS) animations for iOS. An easy to use library of iOS animations. As easy to use as an easy thing.

wobbly See Wobbly in action (examples) Add a drop of honey ?? to your project wobbly has a bunch of cool, fun, and easy to use iOS animations for you

Sagaya Abdulhafeez 150 Dec 23, 2021
PBCircularProgressView is a circular progress view for iOS similar to the app store download progress view.

Overview PBCircularProgressView is a circular progress view for iOS similar to the app store download progress view. It also ha

null 0 Oct 27, 2021
Snake Progress shows circular progress for iOS Apps.

SnakeProgress SnakeProgress shows circular progress for iOS Apps. With SnakeProgress With SnakeProgress, you can easily circular progress. @IBOutlet w

null 8 Sep 22, 2022
UIView based progress bar that shows a progress based on duration in seconds

DurationProgressBar Create a progress bar based on a duration in seconds. The view is fully customisable. Install Add this repository to your swift pa

Cem Olcay 2 May 21, 2022
Open source iOS app to track COVID-19 cases in a beautiful, easy-to-use interface

Covidcheck Covidcheck is an app that allows people to track COVID-19 cases in an easy-to-use interface to increase awareness and preparation. Unfortun

Julian Schiavo 255 Aug 11, 2022
A modern HUD inspired by Apple Music and Apple Podcasts

HUD A modern HUD inspired by Apple Music and Apple Podcasts. Appearance Light Dark HUD Activity Indicator HUD Requirements iOS 13+ Installation You ca

Bei Li 30 Nov 18, 2022
A Swift based reimplementation of the Apple HUD (Volume, Ringer, Rotation,…) for iOS 8.

A Swift based reimplementation of the Apple HUD (Volume, Ringer, Rotation,…) for iOS 8 and up. Features Official iOS 8 blur effect via UIVisualEffects

Philip Kluz 3.7k Jan 9, 2023
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

Harikrishnan T 79 Feb 27, 2021
GUI library for displaying various popups (HUD), written in pure Swift.

SwiftNotice SwiftNotice is a GUI library for displaying various popups (HUD) written in pure Swift, fits any scrollview and supports iPhone X. Feature

John Lui 838 Dec 9, 2022
Customizable HUD for swift

HUD Customizable HUD. Requirements Installation Swift Package Manager The Swift Package Manager is a tool for automating the distribution of Swift cod

Horizontal Systems 1 Oct 6, 2022
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. [

Wilson 583 Dec 6, 2022
Simple HUD.

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

Airin 138 Jan 24, 2021
HUDKit provides HUD interface as UIPresentationController.

HUDKit provides HUD interface as UIPresentationController. Features HUDKit provides HUDPresentationController. This is the HUD interface as an

Hiroki Kato 65 Nov 3, 2020