Git Product home page Git Product logo

jhprogresshud's Introduction

#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 a background thread. The HUD is meant as a replacement for the private UIKit UIProgressHUD.

Screenshots

Adding JHProgressHUD to your project

Source Files

Add the JHProgressHUD.swift file to your project.

  1. Download the latest code version or add the repository as a git submodule to your git-tracked project.
  2. Open your project in Xcode, then drag and drop JHProgressHUD.swift onto your project (use the "Product Navigator view"). Make sure to select Copy items when asked if you extracted the code archive outside of your project.

Usage

The JHProgressHUD is a singleton class and has only a single instance throughout the project. That is you see the same HUD added to multiple views. As a result, HUD duplication doesn't happen. You can use the following code to access the instance of JHProgressHUD anywhere inside the project.

JHProgressHUD.sharedHUD

To show the HUD added to a view, with a title and footer text, use the following code:

JHProgressHUD.sharedHUD.showInView(self.view, withHeader: "Loading", andFooter: "Please Wait")

To show the HUD added to a window, with a title and footer text, use the following code:

JHProgressHUD.sharedHUD.showInWindow(aWindow, withHeader: "Loading", andFooter: "Please Wait")

To show the HUD without any header and footer text added to a view:

JHProgressHUD.sharedHUD.showInView(self.view)

To show the HUD without any header and footer text added to a window:

JHProgressHUD.sharedHUD.showInWindow(aWindow)

To hide the loader, you can call the following function from any class. The HUD will be removed from any view it is shown in:

JHProgressHUD.sharedHUD.hide()

You can also change the colors of different elements of the HUD using the following four properties:

JHProgressHUD.sharedHUD.headerColor = UIColor.redColor() // Changes the color of the title text
JHProgressHUD.sharedHUD.footerColor = UIColor.greenColor() // Changes the color  of the footer text
JHProgressHUD.sharedHUD.backGroundColor = UIColor.blueColor() // Changes the color of the translucent background
JHProgressHUD.sharedHUD.loaderColor = UIColor.yellowColor() // Changes the color of the loading indicator

The HUD might not show if you try to display the loader in a ViewController's viewDidLoad() method, since adding subviews maynot always work in the viewDidLoad(). It is prefered to show the HUD at least only after the viewWillAppear() is called. The HUD blocks the user interaction in the underlying view or window once it is shown, till it is hidden.

License

This code is distributed under the terms and conditions of the MIT license.

jhprogresshud's People

Contributors

harikrishnant1991 avatar rbngzlv avatar

Watchers

Matthew Clark avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.