SVProgressHUD is a clean, lightweight and unobtrusive progress HUD for iOS. It’s a simplified and prettified alternative to the popular MBProgressHUD. Its fade in/out animations are highly inspired on Lauren Britcher’s HUD in Tweetie for iOS. The success and error icons are from Glyphish.
SVProgressHUD features:
- very simple singleton convenience methods
- optional loading, success and error status messages
- automatic positioning based on device type, orientation, and optional
posY
parameter - talks with
setNetworkActivityIndicatorVisible
(default can be changed viaSVProgressHUDShowNetworkIndicator
constant) - optionally disable user interactions while the HUD is showing with the
maskType
parameter
- Drag the
SVProgressHUD/SVProgressHUD
folder into your project. - Add the QuartzCore framework to your project.
If you plan on using SVProgressHUD in a lot of places inside your app, I recommend importing it directly inside your prefix file.
(see sample Xcode project in /Demo
)
SVProgressHUD is created as a singleton (i.e. it doesn’t need to be explicitly allocated and instantiated) and can be shown with the following class methods, depending on the customization level you need to achieve:
+ (void)show; + (void)showInView:(UIView*)view; + (void)showInView:(UIView*)view status:(NSString*)string; + (void)showInView:(UIView*)view status:(NSString*)string networkIndicator:(BOOL)show; + (void)showInView:(UIView*)view status:(NSString*)string networkIndicator:(BOOL)show posY:(CGFloat)posY; + (void)showInView:(UIView*)view status:(NSString*)string networkIndicator:(BOOL)show posY:(CGFloat)posY maskType:(SVProgressHUDMaskType)maskType;
Additional show
convenience methods were recently added:
+ (void)showWithStatus:(NSString*)status; + (void)showWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType; + (void)showWithMaskType:(SVProgressHUDMaskType)maskType;
You dismiss it using one of these:
+ (void)dismiss; + (void)dismissWithSuccess:(NSString*)successString; + (void)dismissWithSuccess:(NSString*)successString afterDelay:(NSTimeInterval)seconds; + (void)dismissWithError:(NSString*)errorString; + (void)dismissWithError:(NSString*)errorString afterDelay:(NSTimeInterval)seconds;
If you’re using SVProgressHUD to show the status of a many-steps operation, you can also change the HUD status while it’s showing with:
+ (void)setStatus:(NSString*)string;
You can optionally disable user interactions and dim the background UI 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) };
By default, showing SVProgressHUD will also show the network activity indicator (this makes sense for apps that make a lot of network operations). You can change this behavior by setting the SVProgressHUDShowNetworkIndicator
constant to 0
in SVProgressHUD.h
.
SVProgressHUD is brought to you by Sam Vermette (@samvermette) and contributors to the project. 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.