Git Product home page Git Product logo

apesuperhud's Introduction

APESuperHUD

A simple way to display a HUD with a message or progress information in your application.

APESuperHUD

Features

  • Simplicity.
  • Customizable. See Change appearance.
  • Fully written in Swift.
  • Unit tests.

Requirements

  • iOS 9 or later.
  • Xcode 9 (Swift 4.1) or later.
    • For Swift 3.0 use version 1.1.3
    • For Swift 2.2 use version 0.6

Installation

CocoaPods

You can use CocoaPods to install APESuperHUD by adding it to your Podfile:

platform :ios, '9.0'
use_frameworks!

target 'MyApp' do
    pod 'APESuperHUD', :git => 'https://github.com/apegroup/APESuperHUD.git'
end

Note that this requires CocoaPods version 36, and your iOS deployment target to be at least 9.0:

Carthage

You can use Carthage to install APESuperHUD by adding it to your Cartfile:

github "apegroup/APESuperHUD"

Usage

Don't forget to import.

import APESuperHUD

Show hud with icon

let image = UIImage(named: "apegroup")!
APESuperHUD.show(style: .icon(image: image, duration: 3.0), title: "Hello", message: "world")

// Or create a instance of APESuperHud

/*
let hudViewController = APESuperHUD(style: .icon(image: image, duration: 3), title: "Hello", message: "world")
present(hudViewController, animated: true)
*/

Show hud with loading indicator

APESuperHUD.show(style: .loadingIndicator(type: .standard), title: nil, message: "Loading...")

DispatchQueue.main.asyncAfter(deadline: .now() + 3.0, execute: {
    APESuperHUD.dismissAll(animated: true)
})

// Or create a instance of APESuperHud

/*
let hudViewController = APESuperHUD(style: .loadingIndicator(type: .standard), title: nil, message: "Loading...")
present(hudViewController, animated: true)

DispatchQueue.main.asyncAfter(deadline: .now() + 3.0, execute: {
    hudViewController.dismiss(animated: true)
})
*/

Show hud with title and message

APESuperHUD.show(style: .textOnly, title: "Hello", message: "world")

DispatchQueue.main.asyncAfter(deadline: .now() + 3.0, execute: {
    APESuperHUD.dismissAll(animated: true)
})

// Or create a instance of APESuperHud

/*
let hudViewController = APESuperHUD(style: .textOnly, title: "Hello", message: "world")
present(hudViewController, animated: true)

DispatchQueue.main.asyncAfter(deadline: .now() + 3.0, execute: {
    hudViewController.dismiss(animated: true)
})
*/

Show hud with updates

APESuperHUD.show(style: .loadingIndicator(type: .standard), title: nil, message: "Loading...")

DispatchQueue.main.asyncAfter(deadline: .now() + 3.0, execute: {
    APESuperHUD.show(style: .textOnly, title: "Done loading", message: nil)

    DispatchQueue.main.asyncAfter(deadline: .now() + 3.0, execute: {
        let image = UIImage(named: "apegroup")!
        APESuperHUD.show(style: .icon(image: image, duration: 3.0), title: nil, message: nil)
    })
})

Change appearance

/// Text color of the title text inside the HUD
HUDAppearance.titleTextColor = UIColor.black

/// Text color of the message text inside the HUD
HUDAppearance.messageTextColor = UIColor.black

/// The color of the icon in the HUD
HUDAppearance.iconColor = UIColor.black

/// The background color of the view where the HUD is presented
HUDAppearance.backgroundColor = UIColor.black.withAlphaComponent(0.5)

/// The background color of the HUD view
HUDAppearance.foregroundColor = UIColor.white

/// The color of the loading indicator
HUDAppearance.loadingActivityIndicatorColor = UIColor.gray

/// The corner radius of the HUD
HUDAppearance.cornerRadius = 10.0

/// Enables/disables shadow effect around the HUD
HUDAppearance.shadow = true

/// The shadow color around the HUD
HUDAppearance.shadowColor = UIColor.black

/// The shadow offset around the HUD
HUDAppearance.shadowOffset = CGSize(width: 0, height: 0)

/// The shadow radius around the HUD
HUDAppearance.shadowRadius = 6.0

/// The shadow opacity around the HUD
HUDAppearance.shadowOpacity = 0.15

/// Enables/disables removal of the HUD if the user taps on the screen
HUDAppearance.cancelableOnTouch = true

/// The info message font in the HUD
HUDAppearance.messageFont = UIFont.systemFont(ofSize: 13, weight: .regular)

/// The title font in the HUD
HUDAppearance.titleFont = UIFont.systemFont(ofSize: 20, weight: .bold)

/// The size of the icon inside the HUD
HUDAppearance.iconSize = CGSize(width: 48, height: 48)

/// The HUD size
HUDAppearance.hudSize = CGSize(width: 144, height: 144)

/// The HUD fade in duration
HUDAppearance.animateInTime = 0.7

/// The HUD fade out duration
HUDAppearance.animateOutTime = 0.7

Contributing

All people are welcome to contribute. See CONTRIBUTING for details.

License

APESuperHUD is released under the MIT license. See LICENSE for details.

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.