@@ -47,7 +47,7 @@ github "Krimpedance/KRProgressHUD"
4747## Usage
4848(see sample Xcode project in /Demo)
4949
50- ###### Caution :
50+ #### Caution :
5151** Only use it if you absolutely need to perform a task before taking the user forward.**
5252
5353** If you want to use it with other cases (ex. pull to refresh), I suggest using [ KRActivityIndicatorView] ( https://github.com/krimpedance/KRActivityIndicator ) .**
@@ -58,101 +58,134 @@ github "Krimpedance/KRProgressHUD"
5858At first, import ` KRProgressHUD ` in your swift file.
5959
6060
61- Show simple HUD (using GCD) :
61+ Show simple HUD :
6262``` Swift
6363KRProgressHUD.show ()
6464
65- let delay = DispatchTime.now () + 1
66- DispatchQueue.main .asyncAfter (deadline : delay) {
67- KRProgressHUD.dismiss ()
65+ DispatchQueue.main .asyncAfter (deadline : DispatchTime.now ()+ 1 ) {
66+ KRProgressHUD.dismiss ()
6867}
6968```
7069
71- #### Showing the HUD
72- You can show HUD with some args.
73- You can appoint only the args which You want to appoint.
74- (Args is reflected only this time.)
70+ ### Showing the HUD
71+
7572``` Swift
76- // progressHUDStyle : background color of progressView
77- // maskType : background color of maskView
78- // activityIndicatorStyle : style of KRActivityIndicatorView
79- // message : Text to display together
80- // image : Image that display instead of activity indicator
81- class func show (
82- progressHUDStyle progressStyle :KRProgressHUDStyle? = nil ,
83- maskType type :KRProgressHUDMaskType? = nil ,
84- activityIndicatorStyle indicatorStyle :KRProgressHUDActivityIndicatorStyle? = nil ,
85- message :String ? = nil ,
86- font :UIFont? = nil ,
87- image :UIImage? = nil ,
88- completion : (()-> ())? = nil
89- )
73+ class func show (withMessage message :String ? = nil , completion : CompleteHandler? = nil )
9074
9175// Example
9276KRProgressHUD.show ()
93- KRProgressHUD.show (message : " Loading..." )
94- KRProgressHUD.show (progressHUDStyle : .black , message : " Loading..." )
95- ...
77+ KRProgressHUD.show (withMessage : " Loading..." )
78+ KRProgressHUD.show (withMessage : " Loading..." ) {
79+ print (" Complete handler" )
80+ }
9681```
9782
98- #### Update the HUD's message
99- The HUD can update message.
83+ ** Show on ViewController**
84+
85+ If you want to show HUD on a view controller, set at ` showOn() ` .
86+
87+ (This is applied only once.)
88+
89+ ``` Swift
90+ KRProgressHUD.showOn (viewController).show ()
91+ ```
92+
93+ Show a confirmation glyph before getting dismissed a little bit later.
94+ (The display time is 1 sec in default. You can change the timing.)
95+
96+ ``` Swift
97+ class func showSuccess ()
98+ class func showInfo ()
99+ class func showWarning ()
100+ class func showError ()
101+ class func showImage () // This can set custom image.
102+ ```
103+
104+ Show the HUD (only message)
105+
100106``` Swift
101- class func update ( text : String )
107+ public class func showMessage ( _ message : String )
102108
103109// Example
104- KRProgressHUD.update ( text : " 20% " )
110+ KRProgressHUD.showMessage ( " Completed! \n Let's start! " )
105111```
106112
107- #### Show the HUD (only message)
108- The HUD can indicate only message.
113+ ### Update the HUD's message
114+ The HUD can update message.
115+
109116``` Swift
110- public class func showText (
111- message : String , font : UIFont? = nil ,
112- centerPosition position : CGPoint? = nil ,
113- progressHUDStyle progressStyle : KRProgressHUDStyle? = nil ,
114- maskType type : KRProgressHUDMaskType? = nil )
117+ class func update (message : String )
115118
116119// Example
117- KRProgressHUD.showText ( " Setup is complete! " )
120+ KRProgressHUD.update ( message : " 20% " )
118121```
119122
120- #### Dismissing the HUD
123+ ### Dismissing the HUD
121124The HUD can be dismissed using:
125+
122126``` Swift
123- class func dismiss (_ completion : (() -> ()) ? )
127+ class func dismiss (_ completion : CompleteHandler ? = nil )
124128```
125- Show a confirmation glyph before getting dismissed a little bit later.
126- (The display time is 1 sec.)
127129
128- These can appoint some args like ` show() ` , too.
130+ ### Customization
131+ ` KRProgressHUD.appearance() ` can set default styles.
129132
130133``` Swift
131- class func showSuccess ()
132- class func showInfo ()
133- class func showWarning ()
134- class func showError ()
134+ class KRProgressHUDAppearance {
135+ /// Default style.
136+ public var style = KRProgressHUDStyle.white
137+ /// Default mask type.
138+ public var maskType = KRProgressHUDMaskType.black
139+ /// Default KRActivityIndicatorView style.
140+ public var activityIndicatorStyle = KRActivityIndicatorViewStyle.gradationColor (head : .black , tail : .lightGray )
141+ /// Default message label font.
142+ public var font = UIFont.systemFont (ofSize : 13 )
143+ /// Default HUD center position.
144+ public var viewCenterPosition = CGPoint (x : UIScreen.main .bounds .width / 2, y: UIScreen. main. bounds. height/ 2 )
145+ /// Default time to show HUD.
146+ public var deadlineTime = Double (1.0 )
147+ }
135148```
136149
137- ## Customization
138- ` KRProgressHUD ` can be customized via the following methods.
150+ When you'd like to make styles reflected only in specific situation, use following methods.
151+
139152``` Swift
140- public class func set (maskType : KRProgressHUDMaskType) // Default is .black
141- public class func set (style : KRProgressHUDStyle) // Default is .white
142- public class func set (activityIndicatorStyle : KRProgressHUDActivityIndicatorStyle) // Default is .black
143- public class func set (font : UIFont) // Default is Hiragino Sans W3 13px (When it can't be used, system font 13px)
144- public class func set (centerPosition : CGPoint) // Default is center of device screen.
153+ @discardableResult public class func set (style : KRProgressHUDStyle) -> KRProgressHUD.Type
154+ @discardableResult public class func set (maskType : KRProgressHUDMaskType) -> KRProgressHUD.Type
155+ @discardableResult public class func set (activityIndicatorViewStyle style : KRActivityIndicatorViewStyle) -> KRProgressHUD.Type
156+ @discardableResult public class func set (font : UIFont) -> KRProgressHUD.Type
157+ @discardableResult public class func set (centerPosition point : CGPoint) -> KRProgressHUD.Type
158+ @discardableResult public class func set (deadlineTime time : Double ) -> KRProgressHUD.Type
159+
160+
161+ // Example
162+ KRProgressHUD
163+ .set (style : .custom (background : .blue , text : .white , icon : nil ))
164+ .set (maskType : .white )
165+ .show ()
166+ ```
167+
168+ These ` set() ` setting can be reset by
169+
170+ ``` Swift
171+ @discardableResult public class func resetStyles () -> KRProgressHUD.Type
145172```
146- ` KRActivityIndicatorView ` 's style, please refer to [ here] ( https://github.com/krimpedance/KRActivityIndicator/blob/master/README.md ) .
147173
148174## Contributing to this project
149175I'm seeking bug reports and feature requests.
150176
151177## Release Note
152- - 2.2.1 : Modify ` M_PI ` to ` Double.pi ` in KRActivityIndicatorView.swift for Swift3 coding.
153- - 2.2.1 : Fixed bug of message label's position after calling ` showText() `
154- - 2.2.0 : Add ` KRProgressHUDStyle.color(background: UIColor, contents: UIColor) ` .
155- This can set custom color of HUD's background and contents(text, glyph icon).
178+ + 3.0.0 :
179+ - [ ADD] Set styles with method chaining.
180+ - [ ADD] Show HUD on VC.
181+
182+ + 2.2.2 :
183+ - [ MODIFY] ` M_PI ` to ` Double.pi `
184+
185+ + 2.2.1 :
186+ - [ BUGFIX] Bug of message label's position after calling ` showText() `
156187
157188## License
158- KRProgressHUD is available under the MIT license. See the LICENSE file for more info.
189+ KRProgressHUD is available under the MIT license.
190+
191+ See the LICENSE file for more info.
0 commit comments