SLAlertView.m 871 B

12345678910111213141516171819202122232425262728
  1. //
  2. // SLAlertView.m
  3. // DarkMode
  4. //
  5. // Created by wsl on 2020/3/11.
  6. // Copyright © 2020 https://github.com/wsl2ls ----- . All rights reserved.
  7. //
  8. #import "SLAlertView.h"
  9. @interface SLAlertView ()
  10. @end
  11. @implementation SLAlertView
  12. /// 展示几秒后自动隐藏
  13. /// @param text 文本
  14. /// @param delay 展示时长
  15. + (void)showAlertViewWithText:(NSString *)text delayHid:(NSTimeInterval)delay {
  16. MBProgressHUD *progressHUD = [[MBProgressHUD alloc] initWithView:[UIApplication sharedApplication].keyWindow];
  17. progressHUD.animationType = MBProgressHUDAnimationFade;
  18. progressHUD.mode = MBProgressHUDModeText;
  19. progressHUD.label.text = text;
  20. progressHUD.label.numberOfLines = 0;
  21. [[UIApplication sharedApplication].keyWindow addSubview:progressHUD];
  22. [progressHUD showAnimated:YES];
  23. [progressHUD hideAnimated:YES afterDelay:delay];
  24. }
  25. @end