STAlertView.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // STAlertView.h
  3. // STModalDemo
  4. //
  5. // Created by zhenlintie on 15/6/5.
  6. // Copyright (c) 2015年 sTeven. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. @interface STAlertView : UIView
  10. /**
  11. * 初始化一个视图
  12. */
  13. - (instancetype)initWithTitle:(NSString *)title
  14. image:(UIImage *)image
  15. message:(NSString *)message
  16. buttonTitles:(NSArray *)buttonTitles;
  17. /**
  18. * 显示/隐藏
  19. */
  20. - (void)show:(BOOL)animated;
  21. - (void)hide:(BOOL)animated;
  22. /**
  23. * 事件回调
  24. */
  25. @property (strong, nonatomic) void (^actionHandler)(NSInteger index);
  26. /**
  27. * 显示隐藏后回调
  28. */
  29. @property (strong, nonatomic) void (^didShowHandler)();
  30. @property (strong, nonatomic) void (^didHideHandler)();
  31. @property (copy, nonatomic, readonly) NSString *title;
  32. @property (copy, nonatomic, readonly) NSString *message;
  33. @property (copy, nonatomic, readonly) UIImage *image;
  34. @property (copy, nonatomic, readonly) NSArray *buttonTitles;
  35. @property (assign, nonatomic, readonly) BOOL onShow;
  36. // 点击外部,是否隐藏,默认NO
  37. @property (assign, nonatomic) BOOL hideWhenTapOutside;
  38. @end
  39. @interface STAlertView (Show)
  40. + (instancetype)showTitle:(NSString *)title
  41. image:(UIImage *)image
  42. message:(NSString *)message
  43. buttonTitles:(NSArray *)buttonTitles
  44. handler:(void(^)(NSInteger index))handler;
  45. + (instancetype)showTitle:(NSString *)title message:(NSString *)message hideDelay:(CGFloat)delay;
  46. + (instancetype)showTitle:(NSString *)title message:(NSString *)message;
  47. @end