/SVProgressHUD

A clean and lightweight progress HUD for your iOS app.

Primary LanguageObjective-COtherNOASSERTION

SVProgressHUD

SVProgressHUD is a clean and easy-to-use HUD meant to display the progress of an ongoing task.

SVProgressHUD

Installation

From CocoaPods

Add pod 'SVProgressHUD' to your Podfile or pod 'SVProgressHUD', :head if you're feeling adventurous.

Manually

Important note if your project doesn't use ARC: you must add the -fobjc-arc compiler flag to SVProgressHUD.m in Target Settings > Build Phases > Compile Sources.

  • Drag the SVProgressHUD/SVProgressHUD folder into your project.
  • Add the QuartzCore framework to your project.

Usage

(see sample Xcode project in /Demo)

SVProgressHUD is created as a singleton (i.e. it doesn't need to be explicitly allocated and instantiated; you directly call [SVProgressHUD method]).

Showing the HUD

You can show the status of indeterminate tasks using:

+ (void)show;
+ (void)showWithMaskType:(SVProgressHUDMaskType)maskType;
+ (void)showWithStatus:(NSString*)string;
+ (void)showWithStatus:(NSString*)string maskType:(SVProgressHUDMaskType)maskType;

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

+ (void)showProgress:(CGFloat)progress;
+ (void)showProgress:(CGFloat)progress status:(NSString*)status;
+ (void)showProgress:(CGFloat)progress status:(NSString*)status maskType:(SVProgressHUDMaskType)maskType;
SVProgressHUDMaskType

You can optionally disable user interactions while the HUD is shown using the maskType property:

enum {
    SVProgressHUDMaskTypeNone = 1, // allow user interactions, don't dim background UI (default)
    SVProgressHUDMaskTypeClear, // disable user interactions, don't dim background UI
    SVProgressHUDMaskTypeBlack, // disable user interactions, dim background UI with 50% translucent black
    SVProgressHUDMaskTypeGradient // disable user interactions, dim background UI with translucent radial gradient (a-la-alertView)
};

Dismissing the HUD

It can be dismissed right away using:

+ (void)dismiss;

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

+ (void)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 1 second later using:

+ (void)showSuccessWithStatus:(NSString*)string;
+ (void)showErrorWithStatus:(NSString *)string;
+ (void)showImage:(UIImage*)image status:(NSString*)string; // use 28x28 white pngs

Credits

SVProgressHUD is brought to you by Sam Vermette and contributors to the project. The success and error icons are from Glyphish. If you have feature suggestions or bug reports, feel free to help out by sending pull requests or by creating new issues. If you're using SVProgressHUD in your project, attribution would be nice.