- iOS 9.+
- Xcode 9.0+
- Swift 4.0+
MKStatusHud is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'MKStatusHud'
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
}
To run the example project, clone the repo, and run pod install
from the Example directory first.
ro6lyo, roshlyo@icloud.com
MKStatusHud is available under the MIT license. See the LICENSE file for more info.