JGProgressHUD

repository·master·Indexed 25 days ago

https://github.com/jonasgessner/jgprogresshud

An elegant and simple progress HUD for iOS and tvOS supporting Swift and Objective-C. It features native looks using UIVisualEffectView, Dark Mode support, and customizable indicator views including pie, ring, success, and error indicators. The library allows for custom animations and background dimming, and can be installed via Swift Package Manager, Carthage, CocoaPods, or manual installation.

Tokens
1.1K
Snippets
4
Records
9
Agent score
36%

What's inside JGProgressHUD

  1. Install JGProgressHUD

    master

    You can install JGProgressHUD using Swift Package Manager (recommended), Carthage, CocoaPods, or manual installation.

    ### Swift Package Manager
    In Xcode, use the menu File > Swift Packages > Add Package Dependency... and enter the package URL `https://github.com/JonasGessner/JGProgressHUD.git`.
    
    ### Carthage
    In your `Cartfile` add:

    github "JonasGessner/JGProgressHUD"

    
    ### CocoaPods
    In your `Podfile` add:

    pod 'JGProgressHUD'

    
    ### Manual Installation
    1. Drag the `JGProgressHUD.xcodeproj` file into your Xcode project.
    2. Add `JGProgressHUD.framework` to "Embedded Binaries" in the "General" tab of your target.
  2. Show determinate progress

    master

    To show a progress bar or ring, set the indicatorView to JGProgressHUDPieIndicatorView or JGProgressHUDRingIndicatorView and set the progress property (0.0 to 1.0).

    // Objective-C
    JGProgressHUD *HUD = [[JGProgressHUD alloc] init];
    HUD.indicatorView = [[JGProgressHUDPieIndicatorView alloc] init]; // Or JGProgressHUDRingIndicatorView
    HUD.progress = 0.5f;
    [HUD showInView:self.view];
    [HUD dismissAfterDelay:3.0];
  3. Show indeterminate progress

    master

    To display a simple loading HUD with an activity indicator and a text label, initialize JGProgressHUD and call show(in:) (Swift) or showInView: (Objective-C).

    // Swift
    let hud = JGProgressHUD()
    hud.textLabel.text = "Loading"
    hud.show(in: self.view)
    hud.dismiss(afterDelay: 3.0)
    
    // Objective-C
    JGProgressHUD *HUD = [[JGProgressHUD alloc] init];
    HUD.textLabel.text = @"Loading";
    [HUD showInView:self.view];
    [HUD dismissAfterDelay:3.0];
  4. Show an error message

    master

    To show an error state, set the indicatorView to an instance of JGProgressHUDErrorIndicatorView.

    // Objective-C
    JGProgressHUD *HUD = [[JGProgressHUD alloc] init];
    HUD.textLabel.text = @"Error";
    HUD.indicatorView = [[JGProgressHUDErrorIndicatorView alloc] init]; // JGProgressHUDSuccessIndicatorView is also available
    [HUD showInView:self.view];
    [HUD dismissAfterDelay:3.0];
  5. Customize Indicator Views

    master

    You can change the HUD's indicator by setting the indicatorView property. Available default indicators include:

    • Indeterminate progress indicator
    • Pie progress indicator
    • Ring progress indicator
    • Success indicator
    • Error indicator
    • Image indicator

    To hide the indicator entirely, set indicatorView to nil. You can also create custom indicators by subclassing JGProgressHUDIndicatorView.