A clean and lightweight progress HUD for your iOS and tvOS app.

Overview

SVProgressHUD

Pod Version Pod Platform Pod License Carthage compatible CocoaPods compatible

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

SVProgressHUD

Demo

Try SVProgressHUD on Appetize.io.

Installation

From CocoaPods

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

pod 'SVProgressHUD'

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

pod 'SVProgressHUD', :git => 'https://github.com/SVProgressHUD/SVProgressHUD.git'

This pulls from the master branch directly.

Second, install SVProgressHUD into your project:

pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate SVProgressHUD into your Xcode project using Carthage, specify it in your Cartfile:

github "SVProgressHUD/SVProgressHUD"

Run carthage bootstrap to build the framework in your repository's Carthage directory. You can then include it in your target's carthage copy-frameworks build phase. For more information on this, please see Carthage's documentation.

Manually

  • Drag the SVProgressHUD/SVProgressHUD folder into your project.
  • Take care that SVProgressHUD.bundle is added to Targets->Build Phases->Copy Bundle Resources.
  • Add the QuartzCore framework to your project.

Swift

Even though SVProgressHUD is written in Objective-C, it can be used in Swift with no hassle. If you use CocoaPods add the following line to your Podfile:

use_frameworks!

If you added SVProgressHUD manually, just add a bridging header file to your project with the SVProgressHUD header included.

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]).

Use SVProgressHUD 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 SVProgressHUD in your app will usually look as simple as this (using Grand Central Dispatch):

[SVProgressHUD show];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    // time-consuming task
    dispatch_async(dispatch_get_main_queue(), ^{
        [SVProgressHUD dismiss];
    });
});

Showing the HUD

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

+ (void)show;
+ (void)showWithStatus:(NSString*)string;

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

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

Dismissing the HUD

The HUD can be dismissed using:

+ (void)dismiss;
+ (void)dismissWithDelay:(NSTimeInterval)delay;

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 a little bit later. The display time depends on minimumDismissTimeInterval and the length of the given string.

+ (void)showInfoWithStatus:(NSString*)string;
+ (void)showSuccessWithStatus:(NSString*)string;
+ (void)showErrorWithStatus:(NSString*)string;
+ (void)showImage:(UIImage*)image status:(NSString*)string;

Customization

SVProgressHUD can be customized via the following methods:

+ (void)setDefaultStyle:(SVProgressHUDStyle)style;                  // default is SVProgressHUDStyleLight
+ (void)setDefaultMaskType:(SVProgressHUDMaskType)maskType;         // default is SVProgressHUDMaskTypeNone
+ (void)setDefaultAnimationType:(SVProgressHUDAnimationType)type;   // default is SVProgressHUDAnimationTypeFlat
+ (void)setContainerView:(UIView*)containerView;                    // default is window level
+ (void)setMinimumSize:(CGSize)minimumSize;                         // default is CGSizeZero, can be used to avoid resizing
+ (void)setRingThickness:(CGFloat)width;                            // default is 2 pt
+ (void)setRingRadius:(CGFloat)radius;                              // default is 18 pt
+ (void)setRingNoTextRadius:(CGFloat)radius;                        // default is 24 pt
+ (void)setCornerRadius:(CGFloat)cornerRadius;                      // default is 14 pt
+ (void)setBorderColor:(nonnull UIColor*)color;                     // default is nil
+ (void)setBorderWidth:(CGFloat)width;                              // default is 0
+ (void)setFont:(UIFont*)font;                                      // default is [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline]
+ (void)setForegroundColor:(UIColor*)color;                         // default is [UIColor blackColor], only used for SVProgressHUDStyleCustom
+ (void)setForegroundImageColor:(nullable UIColor*)color;           // default is the same as foregroundColor
+ (void)setBackgroundColor:(UIColor*)color;                         // default is [UIColor whiteColor], only used for SVProgressHUDStyleCustom
+ (void)setBackgroundLayerColor:(UIColor*)color;                    // default is [UIColor colorWithWhite:0 alpha:0.4], only used for SVProgressHUDMaskTypeCustom
+ (void)setImageViewSize:(CGSize)size;                              // default is 28x28 pt
+ (void)setShouldTintImages:(BOOL)shouldTintImages;                 // default is YES
+ (void)setInfoImage:(UIImage*)image;                               // default is the bundled info image provided by Freepik
+ (void)setSuccessImage:(UIImage*)image;                            // default is bundled success image from Freepik
+ (void)setErrorImage:(UIImage*)image;                              // default is bundled error image from Freepik
+ (void)setViewForExtension:(UIView*)view;                          // default is nil, only used if #define SV_APP_EXTENSIONS is set
+ (void)setGraceTimeInterval:(NSTimeInterval)interval;              // default is 0 seconds
+ (void)setMinimumDismissTimeInterval:(NSTimeInterval)interval;     // default is 5.0 seconds
+ (void)setMaximumDismissTimeInterval:(NSTimeInterval)interval;     // default is CGFLOAT_MAX
+ (void)setFadeInAnimationDuration:(NSTimeInterval)duration;        // default is 0.15 seconds
+ (void)setFadeOutAnimationDuration:(NSTimeInterval)duration;       // default is 0.15 seconds
+ (void)setMaxSupportedWindowLevel:(UIWindowLevel)windowLevel;      // default is UIWindowLevelNormal
+ (void)setHapticsEnabled:(BOOL)hapticsEnabled;                     // default is NO

Additionally SVProgressHUD supports the UIAppearance protocol for most of the above methods.

Hint

As standard SVProgressHUD offers two preconfigured styles:

  • SVProgressHUDStyleLight: White background with black spinner and text
  • SVProgressHUDStyleDark: 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 SVProgressHUDStyleCustom.

Haptic Feedback

For users with newer devices (starting with the iPhone 7), SVProgressHUD 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

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

  • SVProgressHUDWillAppearNotification when the show animation starts
  • SVProgressHUDDidAppearNotification when the show animation completes
  • SVProgressHUDWillDisappearNotification when the dismiss animation starts
  • SVProgressHUDDidDisappearNotification when the dismiss animation completes

Each notification passes a userInfo dictionary holding the HUD's status string (if any), retrievable via SVProgressHUDStatusUserInfoKey.

SVProgressHUD also posts SVProgressHUDDidReceiveTouchEventNotification when users touch on the overall screen or SVProgressHUDDidTouchDownInsideNotification 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 SVProgressHUD in an App Extension, #define SV_APP_EXTENSIONS to avoid using unavailable APIs. Additionally call setViewForExtension: from your extensions view controller with self.view.

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

SVProgressHUD 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

SVProgressHUD is brought to you by Sam Vermette, Tobias Tiemerding and contributors to the project. If you're using SVProgressHUD in your project, attribution would be very appreciated.

Comments
  • Missing SVProgressHUD.bundle when installing SVProgressHUD 1.1.3 via Cocoapods

    Missing SVProgressHUD.bundle when installing SVProgressHUD 1.1.3 via Cocoapods

    I recently attempted to do pod install, after updating my SVProgressHUD from 1.1.2 to 1.1.3, and SVProgressHUD.bundle seemed to be missing.

    In SVProgressHUD.m:266:

    NSURL *url = [bundle URLForResource:@"SVProgressHUD" withExtension:@"bundle"];

    url will return nil, triggering an exception on the next line:

    NSBundle *imageBundle = [NSBundle bundleWithURL:url];

    The exception is as follows:

    *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSBundle initWithURL:]: nil URL argument'

    Manually dragging the SVProgressHUD.bundle from the Pods/SVProgressHUD/SVProgressHUD/ folder on the filesystem, into my Xcode project (which is in the embedded Xcode workspace) will get rid of this exception.

    bug investigating 
    opened by yujean 36
  • New collaborators to keep the component alive?

    New collaborators to keep the component alive?

    Dear Sam.

    SVProgressHUD is used in many many Apps, therefore it is important to keep the component up to date. This include especially bugfixes for recent OS updates like iOS 8. As you can see this is not the case anymore (#342, #351, #334, #331, ...). The community is providing Pull-Request for these problems, however they are not merged <=> the master branch is inactive, the component quasi defective on iOS 8.

    You have done great work in the last years regarding this component. However, in consideration of the current state I would like to ask you to think about how to continue with this component. How could the community help you to keep the component alive. My idea: Add collaborators to the project, which for example may merge Pull-Requests in the future. What do you think?

    BR

    opened by honkmaster 36
  • Add HUD to UIPopoverController instead to a UIWindow

    Add HUD to UIPopoverController instead to a UIWindow

    I am having problems adding HUD to UIPopover. It's actually shown over the whole UIWindow instead of just over the popover. Am I doing smth wrong or is this just as-is?

    investigating waiting 
    opened by borut-t 32
  • presentViewController with [SVProgressHUD dismiss]

    presentViewController with [SVProgressHUD dismiss]

    When I called

    [SVProgressHUD dismiss];

    in presentView controller , the previous ViewController is appear and current presentViewController is lost.

    I checked your code and I found

    [[UIApplication sharedApplication].windows.lastObject makeKeyAndVisible];

    I commented it and it's working fine for me.

    opened by saturngod 30
  • HUD not showing on root view controller in viewDidLoad and viewWillAppear methods

    HUD not showing on root view controller in viewDidLoad and viewWillAppear methods

    I found a bug where SVProgressHUD does not display in viewDidLoad and viewWillAppear on the initial/root view controller. it works correctly in any other subsequent VC, or if the initial view controller is embed in a navigation controller. I attached bellow what I found and different solutions:

    TTest.zip

    @honkmaster this is related to https://github.com/SVProgressHUD/SVProgressHUD/issues/315

    Thanks!

    opened by allaire 29
  • On iPad using iOS 8 the mask doesn't cover the full screen

    On iPad using iOS 8 the mask doesn't cover the full screen

    I'm using SVProgressHUDMaskTypeBlack and sometimes (?!) the mask doesn't cover the full screen. Using it with cocoapods pointing to head: pod 'SVProgressHUD', :head The orientation of the indicator looks good but there's the issue with the mask.

    opened by cromandini 28
  • iOS 8: SVProgressHUD Activity indicator is not centered aligned properly in Landscape mode in iOS 8.

    iOS 8: SVProgressHUD Activity indicator is not centered aligned properly in Landscape mode in iOS 8.

    Can somebody help me out to fix this issue. I tried by taking the keywindow frame then also the loading Activity Indicator is not centered aligned in Landscape mode in iOS 8 simulators and devices.

    investigating 
    opened by csumanth 25
  • ARC don't work on iOS 4

    ARC don't work on iOS 4

    I have a question about it, i doing an app that is compatible for ios 4 and ios 5, and i see you have used ARC, but on ios 4 it's not compatible, and give me some warning, and then crashing using it on ios 4:

    -No 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed -Default property attribute 'assign' not appropriate for non-gc object -Method possibly missing a [super dealloc] call

    how i can do to solve it, to use on ios 4 and ios 5?

    Thanks!

    opened by Piero87 25
  • iOS 7 styling

    iOS 7 styling

    Here's a possible implementation of iOS 7 styling.

    With this code, on iOS 7, the progress hud will default to a light, translucent, blurring background, with dark text. The tint color can be changed using the appearance proxy.

    This isn't totally done, but I wanted to get initial feedback on this, and see if anyone else is interested in wrapping it up.

    Issues:

    • The "success" and "failure" images are only white, so we'll need black versions for this
    • Customizing whether the progress hud is translucent on iOS 7 is not implemented
    • I made the progress HUD larger to more closely match the ring switch / volume HUD on iOS 7, but now the layout code needs to be rewritten to center the content vertically

    Screenshots: image image image

    opened by getaaron 24
  • problem of using in xcode10.2

    problem of using in xcode10.2

    when I debug in xcode,SVProgressHUD first call in my project,it will pause UI and Data handle for a while。I don't know Whether or not because the xcode version,It won't be like this until it's updated.

    =================================================================
    Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
    PID: 4231, TID: 1211204, Thread name: com.apple.CoreMotion.MotionThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
    Backtrace:
    4   libobjc.A.dylib                     0x00000001b2c93534 <redacted> + 56
    5   CoreMotion                          0x00000001b951c040 CoreMotion + 307264
    6   CoreMotion                          0x00000001b951c574 CoreMotion + 308596
    7   CoreMotion                          0x00000001b951c484 CoreMotion + 308356
    8   CoreMotion                          0x00000001b954dc64 CoreMotion + 511076
    9   CoreMotion                          0x00000001b954dcc4 CoreMotion + 511172
    10  CoreFoundation                      0x00000001b3a2c354 <redacted> + 28
    11  CoreFoundation                      0x00000001b3a2bc38 <redacted> + 276
    12  CoreFoundation                      0x00000001b3a26f14 <redacted> + 2324
    13  CoreFoundation                      0x00000001b3a262e8 CFRunLoopRunSpecific + 452
    14  CoreFoundation                      0x00000001b3a2704c CFRunLoopRun + 84
    15  CoreMotion                          0x00000001b954d5fc CoreMotion + 509436
    16  libsystem_pthread.dylib             0x00000001b36a0974 <redacted> + 132
    17  libsystem_pthread.dylib             0x00000001b36a08d0 _pthread_start + 52
    18  libsystem_pthread.dylib             0x00000001b36a8ddc thread_start + 4
    2019-03-30 16:46:06.431304+0800 DLMSDKDemo[4231:1211204] [reports] Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
    PID: 4231, TID: 1211204, Thread name: com.apple.CoreMotion.MotionThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
    Backtrace:
    4   libobjc.A.dylib                     0x00000001b2c93534 <redacted> + 56
    5   CoreMotion                          0x00000001b951c040 CoreMotion + 307264
    6   CoreMotion                          0x00000001b951c574 CoreMotion + 308596
    7   CoreMotion                          0x00000001b951c484 CoreMotion + 308356
    8   CoreMotion                          0x00000001b954dc64 CoreMotion + 511076
    9   CoreMotion                          0x00000001b954dcc4 CoreMotion + 511172
    10  CoreFoundation                      0x00000001b3a2c354 <redacted> + 28
    11  CoreFoundation                      0x00000001b3a2bc38 <redacted> + 276
    12  CoreFoundation                      0x00000001b3a26f14 <redacted> + 2324
    13  CoreFoundation                      0x00000001b3a262e8 CFRunLoopRunSpecific + 452
    14  CoreFoundation                      0x00000001b3a2704c CFRunLoopRun + 84
    15  CoreMotion                          0x00000001b954d5fc CoreMotion + 509436
    16  libsystem_pthread.dylib             0x00000001b36a0974 <redacted> + 132
    17  libsystem_pthread.dylib             0x00000001b36a08d0 _pthread_start + 52
    18  libsystem_pthread.dylib             0x00000001b36a8ddc thread_start + 4
    
    opened by change1wang73 23
  • First HUD display always has no background

    First HUD display always has no background

    Weird stuff, the first HUD that I show always has no background, but every subsequent HUD has one according to the appearance I've set in my app delegate. Using latest head.

    Thanks!

    opened by allaire 23
  • 有没有单独控制显示与隐藏的哪?

    有没有单独控制显示与隐藏的哪?

    For example, when I pop up a warning box, the loading box is still turning. When the turning is completed, I only hide the loading box, not the warning box. After "dismiss", I hid it all. Would you please tell me what to do?

    比如我在弹出一个警告框的时候,这个时候加载框还在转圈,当转圈完成后,我只隐藏加载框,而不会隐藏警告框。我在dismiss之后,就全部隐藏了。烦请告知我该怎么做?

    opened by nodkH 0
  • Update imageUsed judgment conditions when set imageViewSize to zero

    Update imageUsed judgment conditions when set imageViewSize to zero

    when I set setImageViewSize(.zero), hudView will show a top margin

    image

    --------------------------------------------------------------------------------------------------------------------- After modification image

    opened by foermo4-hao 1
  • SVProgressHud Package dependency installation issue

    SVProgressHud Package dependency installation issue

    i am trying to install SVProgressHUD with package dependency and getting the following error:

    /Package.swift has no Package.swift manifest in https://github.com/SVProgressHUD/SVProgressHUD.git

    opened by Taimoor20 0
Owner
SVProgressHUD
A clean and lightweight progress HUD for your iOS and tvOS app.
SVProgressHUD
A simple modal progress HUD (heads-up display, or progress indicator) for flutter

modal_progress_hud A simple widget wrapper to enable modal progress HUD (a modal progress indicator, HUD = Heads Up Display) Inspired by this article.

Maurice McCabe 158 Nov 16, 2022
Flutter package to diplay progress through a milestone progress widget

milestone_progress Flutter package for IOS and Android to display progress through milestone progress widget. Screenshots ## Usage [Example]https://gi

Harpreet Singh 16 Aug 4, 2020
Wave progress - A custom wave progress widget

wave_progress_widget A customable wave progress widget Preview How to use Add this to your package's pubspec.yaml file: dependencies: wave_progress_

idan ben shimon 41 Jul 18, 2022
A lightweight flutter plugin to check if your app is up-to-date on Google Play Store or Apple App Store

App Version Checker this package is used to check if your app has a new version on playstore or apple app store. or you can even check what is the lat

Iheb Briki 7 Nov 2, 2022
Ouday 22 Nov 13, 2022
clean architecture and clean code with flutter , with bloc and getx state managment .

example_bloc A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if

Khaled ElTohamy 6 Aug 22, 2022
Flutter-clean-architecture - A simple flutter project developed with TDD and using Clean Architecture principles.

Clean Architecture This is a study project to practice TDD and a good approach of Clean Architecture for flutter projects. It is based on Reso Coder s

Luiz Paulo Franz 8 Jul 21, 2022
The typesafe, reactive, and lightweight SQLite abstraction for your Flutter applications

See the project's website for the full documentation. Floor provides a neat SQLite abstraction for your Flutter applications inspired by the Room pers

Vitus 777 Nov 12, 2022
A lightweight and customizable http client that allows you to create offline-first dart app easily.

Enjoyable & customizable offline-first REST API client Unruffled is lightweight and customizable http client that allows you to create offline-first e

T. Milian 3 May 20, 2022
Bhagavad Gita app using flutter & Bhagavad-Gita-API is A lightweight Node.js based Bhagavad Gita API [An open source rest api on indian Vedic Scripture Shrimad Bhagavad Gita].

Gita Bhagavad Gita flutter app. Download App - Playstore Web Application About Bhagavad Gita app using flutter & Bhagavad-Gita-API is A lightweight No

Ravi Kovind 7 Apr 5, 2022
Fa-chapter-2 - Lightweight Recipe App Built With Flutter

Recipe App Our app will offer a hard-coded list of recipes and let us use a Slid

Siphumelelo Talent Qwabe 0 Jan 2, 2022
A lightweight & effective Todo app made with Flutter

Blue Diary A lightweight & effective Todo app made with Flutter. Supports English and Korean. Screenshots • Download • Usage • Architecture • Feedback

Hansol Lee 152 Nov 2, 2022
The lightweight and powerful wrapper library for Twitter Ads API written in Dart and Flutter 🐦

TODO: Put a short description of the package here that helps potential users know whether this package might be useful for them. Features TODO: List w

Twitter.dart 2 Aug 26, 2022
A lightweight flutter package to linkify texts containing urls, emails and hashtags

linkfy_text A lightweight flutter package to linkify texts containing urls, emails and hashtags. Usage To use this package, add linkfy_text as a depen

Stanley Akpama 15 Oct 17, 2022
Lightweight and blazing fast key-value database written in pure Dart.

Fast, Enjoyable & Secure NoSQL Database Hive is a lightweight and blazing fast key-value database written in pure Dart. Inspired by Bitcask. Documenta

HiveDB 3.3k Nov 26, 2022
Lightweight and blazing fast key-value database written in pure Dart.

Fast, Enjoyable & Secure NoSQL Database Hive is a lightweight and blazing fast key-value database written in pure Dart. Inspired by Bitcask. Documenta

HiveDB 3.3k Nov 16, 2022
Easy to use, reliable and lightweight gesture detector for Flutter apps, exposing simple API for basic gestures

Simple Gesture Detector Easy to use, reliable and lightweight gesture detector for Flutter apps. Exposes simple API to react to basic gestures. Featur

Aleksander Woźniak 26 Nov 4, 2022
Zerker is a lightweight and powerful flutter graphic animation library

What is Zerker Zerker is a flexible and lightweight flutter canvas graphic animation library. With Zerker, you can create a lot of seemingly cumbersom

FlutterKit 515 Nov 16, 2022