Skip to content

A Swift based reimplementation of the Apple HUD with After Effects vector animations

License

Notifications You must be signed in to change notification settings

ro6lyo/MKStatusHud

Repository files navigation

MKStatusHud

Version License Platform

Demo

Gif Gif Gif Gif

Requirements

  • iOS 9.+
  • Xcode 9.0+
  • Swift 4.0+

Installation

MKStatusHud is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'MKStatusHud'

Usage

After adding the framework to your project, you need to import the modules

import MKStatusHud
import Lottie

Now, you can proceed to create an arbitrary HUD with image like this:

let hud = HUD(withImage: UIImage()), title: "Please wait!", subtitle: "While download proccess completes.")

or you can create HUD with adobe After Efect animation like this:

let hud = HUD(withAnimation: LOTAnimationView(name: "loader-success-failed"), title: "Please wait!", subtitle: "While download proccess completes.")

alternatively you can customize the hud and animation behavior with lots of "plumbing" API:

hud.rotation            // rotates  hud image
hud.presentOnView       // if provided will present hud on that view, other ways it will use UIApplication.keywindow

Animation quick settings, you can use those, or you can manipulate animation directly:

hud.animateToProgress   // plays animation to the given progress
hud.animationLoop       // loops the animation
hud.animationScale      // scales the animation

When you done setting up the hud, you can present it:

   hud.show({(_) in
            // start network request and wait for response
            // some time later update the hud with the response status 
            //...//
            hud.update(withImage: UIImage(), title: "Done!", subtitle: "Download completed.",rotation: false,dismiss:10)
            //or if its a hud with vector animation you can update animation in realtime
            hud.animateToProgress = 0.47
            hud.animationLoop = false
            hud.update()
            
        }, progress: { (progress) in
            // progres block calls recieved in every 0.5s.
        }, animation: { (isCompleted) in
            // calls when vector animation stops and indicates if it is finished or not
            if isCompleted {
                hud.updateWith(title: "Done!", subtitle: "Process completed.")
                hud.close(hideAfter: 2)
            }
        }) { (isClosed) in
            // calls when the hud gets dissmissed
        }

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Author

ro6lyo, roshlyo@icloud.com

License

MKStatusHud is available under the MIT license. See the LICENSE file for more info.

About

A Swift based reimplementation of the Apple HUD with After Effects vector animations

Resources

License

Stars

Watchers

Forks

Packages

No packages published