SVProgressHUD.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. //
  2. // SVProgressHUD.h
  3. // SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD
  4. //
  5. // Copyright (c) 2011-2016 Sam Vermette and contributors. All rights reserved.
  6. //
  7. #import <UIKit/UIKit.h>
  8. #import <AvailabilityMacros.h>
  9. #if __IPHONE_OS_VERSION_MAX_ALLOWED < 70000
  10. #define UI_APPEARANCE_SELECTOR
  11. #endif
  12. extern NSString * const SVProgressHUDDidReceiveTouchEventNotification;
  13. extern NSString * const SVProgressHUDDidTouchDownInsideNotification;
  14. extern NSString * const SVProgressHUDWillDisappearNotification;
  15. extern NSString * const SVProgressHUDDidDisappearNotification;
  16. extern NSString * const SVProgressHUDWillAppearNotification;
  17. extern NSString * const SVProgressHUDDidAppearNotification;
  18. extern NSString * const SVProgressHUDStatusUserInfoKey;
  19. typedef NS_ENUM(NSInteger, SVProgressHUDStyle) {
  20. SVProgressHUDStyleLight, // default style, white HUD with black text, HUD background will be blurred on iOS 8 and above
  21. SVProgressHUDStyleDark, // black HUD and white text, HUD background will be blurred on iOS 8 and above
  22. SVProgressHUDStyleCustom // uses the fore- and background color properties
  23. };
  24. typedef NS_ENUM(NSUInteger, SVProgressHUDMaskType) {
  25. SVProgressHUDMaskTypeNone = 1, // default mask type, allow user interactions while HUD is displayed
  26. SVProgressHUDMaskTypeClear, // don't allow user interactions
  27. SVProgressHUDMaskTypeBlack, // don't allow user interactions and dim the UI in the back of the HUD, as on iOS 7 and above
  28. SVProgressHUDMaskTypeGradient, // don't allow user interactions and dim the UI with a a-la UIAlertView background gradient, as on iOS 6
  29. SVProgressHUDMaskTypeCustom // don't allow user interactions and dim the UI in the back of the HUD with a custom color
  30. };
  31. typedef NS_ENUM(NSUInteger, SVProgressHUDAnimationType) {
  32. SVProgressHUDAnimationTypeFlat, // default animation type, custom flat animation (indefinite animated ring)
  33. SVProgressHUDAnimationTypeNative // iOS native UIActivityIndicatorView
  34. };
  35. @interface SVProgressHUD : UIView
  36. #pragma mark - Customization
  37. @property (assign, nonatomic) SVProgressHUDStyle defaultStyle UI_APPEARANCE_SELECTOR; // default is SVProgressHUDStyleLight
  38. @property (assign, nonatomic) SVProgressHUDMaskType defaultMaskType UI_APPEARANCE_SELECTOR; // default is SVProgressHUDMaskTypeNone
  39. @property (assign, nonatomic) SVProgressHUDAnimationType defaultAnimationType UI_APPEARANCE_SELECTOR; // default is SVProgressHUDAnimationTypeFlat
  40. @property (assign, nonatomic) CGSize minimumSize UI_APPEARANCE_SELECTOR; // default is CGSizeZero, can be used to avoid resizing for a larger message
  41. @property (assign, nonatomic) CGFloat ringThickness UI_APPEARANCE_SELECTOR; // default is 2 pt
  42. @property (assign, nonatomic) CGFloat ringRadius UI_APPEARANCE_SELECTOR; // default is 18 pt
  43. @property (assign, nonatomic) CGFloat ringNoTextRadius UI_APPEARANCE_SELECTOR; // default is 24 pt
  44. @property (assign, nonatomic) CGFloat cornerRadius UI_APPEARANCE_SELECTOR; // default is 14 pt
  45. @property (strong, nonatomic) UIFont *font UI_APPEARANCE_SELECTOR; // default is [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline]
  46. @property (strong, nonatomic) UIColor *backgroundColor UI_APPEARANCE_SELECTOR; // default is [UIColor whiteColor]
  47. @property (strong, nonatomic) UIColor *foregroundColor UI_APPEARANCE_SELECTOR; // default is [UIColor blackColor]
  48. @property (strong, nonatomic) UIColor *backgroundLayerColor UI_APPEARANCE_SELECTOR; // default is [UIColor colorWithWhite:0 alpha:0.4]
  49. @property (strong, nonatomic) UIImage *infoImage UI_APPEARANCE_SELECTOR; // default is the bundled info image provided by Freepik
  50. @property (strong, nonatomic) UIImage *successImage UI_APPEARANCE_SELECTOR; // default is the bundled success image provided by Freepik
  51. @property (strong, nonatomic) UIImage *errorImage UI_APPEARANCE_SELECTOR; // default is the bundled error image provided by Freepik
  52. @property (strong, nonatomic) UIView *viewForExtension UI_APPEARANCE_SELECTOR; // default is nil, only used if #define SV_APP_EXTENSIONS is set
  53. @property (assign, nonatomic) NSTimeInterval minimumDismissTimeInterval; // default is 5.0 seconds
  54. @property (assign, nonatomic) UIOffset offsetFromCenter UI_APPEARANCE_SELECTOR; // default is 0, 0
  55. @property (assign, nonatomic) NSTimeInterval fadeInAnimationDuration; // default is 0.15
  56. @property (assign, nonatomic) NSTimeInterval fadeOutAnimationDuration; // default is 0.15
  57. + (void)setDefaultStyle:(SVProgressHUDStyle)style; // default is SVProgressHUDStyleLight
  58. + (void)setDefaultMaskType:(SVProgressHUDMaskType)maskType; // default is SVProgressHUDMaskTypeNone
  59. + (void)setDefaultAnimationType:(SVProgressHUDAnimationType)type; // default is SVProgressHUDAnimationTypeFlat
  60. + (void)setMinimumSize:(CGSize)minimumSize; // default is CGSizeZero, can be used to avoid resizing for a larger message
  61. + (void)setRingThickness:(CGFloat)ringThickness; // default is 2 pt
  62. + (void)setRingRadius:(CGFloat)radius; // default is 18 pt
  63. + (void)setRingNoTextRadius:(CGFloat)radius; // default is 24 pt
  64. + (void)setCornerRadius:(CGFloat)cornerRadius; // default is 14 pt
  65. + (void)setFont:(UIFont*)font; // default is [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline]
  66. + (void)setForegroundColor:(UIColor*)color; // default is [UIColor blackColor], only used for SVProgressHUDStyleCustom
  67. + (void)setBackgroundColor:(UIColor*)color; // default is [UIColor whiteColor], only used for SVProgressHUDStyleCustom
  68. + (void)setBackgroundLayerColor:(UIColor*)color; // default is [UIColor colorWithWhite:0 alpha:0.5], only used for SVProgressHUDMaskTypeBlack
  69. + (void)setInfoImage:(UIImage*)image; // default is the bundled info image provided by Freepik
  70. + (void)setSuccessImage:(UIImage*)image; // default is the bundled success image provided by Freepik
  71. + (void)setErrorImage:(UIImage*)image; // default is the bundled error image provided by Freepik
  72. + (void)setViewForExtension:(UIView*)view; // default is nil, only used if #define SV_APP_EXTENSIONS is set
  73. + (void)setMinimumDismissTimeInterval:(NSTimeInterval)interval; // default is 5.0 seconds
  74. + (void)setFadeInAnimationDuration:(NSTimeInterval)duration; // default is 0.15 seconds
  75. + (void)setFadeOutAnimationDuration:(NSTimeInterval)duration; // default is 0.15 seconds
  76. #pragma mark - Show Methods
  77. + (void)show;
  78. + (void)showWithMaskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use show and setDefaultMaskType: instead.")));
  79. + (void)showWithStatus:(NSString*)status;
  80. + (void)showWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showWithStatus: and setDefaultMaskType: instead.")));
  81. + (void)showProgress:(float)progress;
  82. + (void)showProgress:(float)progress maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showProgress: and setDefaultMaskType: instead.")));
  83. + (void)showProgress:(float)progress status:(NSString*)status;
  84. + (void)showProgress:(float)progress status:(NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showProgress:status: and setDefaultMaskType: instead.")));
  85. + (void)setStatus:(NSString*)status; // change the HUD loading status while it's showing
  86. // stops the activity indicator, shows a glyph + status, and dismisses the HUD a little bit later
  87. + (void)showInfoWithStatus:(NSString*)status;
  88. + (void)showInfoWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showInfoWithStatus: and setDefaultMaskType: instead.")));
  89. + (void)showSuccessWithStatus:(NSString*)status;
  90. + (void)showSuccessWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showSuccessWithStatus: and setDefaultMaskType: instead.")));
  91. + (void)showErrorWithStatus:(NSString*)status;
  92. + (void)showErrorWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showErrorWithStatus: and setDefaultMaskType: instead.")));
  93. // shows a image + status, use 28x28 white PNGs
  94. + (void)showImage:(UIImage*)image status:(NSString*)status;
  95. + (void)showImage:(UIImage*)image status:(NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showImage:status: and setDefaultMaskType: instead.")));
  96. + (void)setOffsetFromCenter:(UIOffset)offset;
  97. + (void)resetOffsetFromCenter;
  98. + (void)popActivity; // decrease activity count, if activity count == 0 the HUD is dismissed
  99. + (void)dismiss;
  100. + (void)dismissWithDelay:(NSTimeInterval)delay;
  101. + (BOOL)isVisible;
  102. + (NSTimeInterval)displayDurationForString:(NSString*)string;
  103. @end