** PKHUD ** is a library for displaying ** HUD (Head-Up Display) **. You can use the HUD to tell the user that something is happening or completed.
PKHUD can be installed using either CocoaPods or Carthage. In this article, I will introduce using CocoaPods.
//Describe the following pod in the Podfile'pod install'In the terminal
pod 'PKHUD'
//Import to the file you want to use PKHUD
import PKHUD
==================================================================
① Basic usage
//Display of loading
HUD.show(.progress)
//Hide loading
HUD.hide(animation: true)
==================================================================
==================================================================
② Success/Display of failure
//Show success
HUD.flash(.success)
//Display of failure
HUD.flash(.error)
==================================================================
==================================================================
③ Loading / success / failure display (with text)
//Display loading by specifying text
HUD.show(.labelProgress(title: "Write text here", subtitle: nil))
//Specify text to show success
HUD.flash(.labeledSuccess(title: "Success", subtitle: nil))
//Show failure by specifying text
HUD.flash(.labeledError(title: "Error", subtitle: nil))
==================================================================
==================================================================
④ Display only in text
HUD.show(.label("Write text here"))
==================================================================
By default, the background view of the HUD will be dimmed and users will not be able to interact with the app during that time. However, there may be situations where you want the user to be able to operate it. I will also digest the implementation method in such cases.
//Allows you to manipulate the background view of the HUD
HUD.allowsInteraction = true
//Do not darken the background view of the HUD
HUD.dimsBackground = false
please refer!
Recommended Posts