ShowKeepNoticeAlert.m 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //
  2. // ShowKeepNoticeAlert.m
  3. // smartRhino
  4. //
  5. // Created by armin on 2019/11/6.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "ShowKeepNoticeAlert.h"
  9. @interface ShowKeepNoticeAlert()
  10. @property (strong,nonatomic) IBOutlet UIView *contentBgView;
  11. @property (copy, nonatomic) void(^confirmBlock)(void);
  12. @property (copy, nonatomic) void(^cancelBlock)(ShowKeepNoticeCloseType colseType);
  13. @end
  14. @implementation ShowKeepNoticeAlert
  15. static UINib *ViewNib = nil;
  16. + (instancetype)selectView{
  17. if (ViewNib == nil) {
  18. ViewNib = [UINib nibWithNibName:@"ShowKeepNoticeAlert" bundle:nil];
  19. }
  20. ShowKeepNoticeAlert *alert = [[ViewNib instantiateWithOwner:nil options:nil] lastObject];
  21. return alert;
  22. }
  23. /**
  24. * 初始化
  25. */
  26. +(instancetype)initShowKeepNoticeAlertConfirm:(void (^)(void))confirmBlock cancle:(void (^)(ShowKeepNoticeCloseType closeType))cancleBlock{
  27. ShowKeepNoticeAlert *alert = [self selectView];
  28. [alert setFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
  29. alert.contentBgView.backgroundColor = [UIColor whiteColor];
  30. alert.contentBgView.width = SCREEN_WIDTH - 2*55;
  31. [alert.contentBgView setRadius:8 corners:UIRectCornerAllCorners];
  32. [alert setStatusBarStyle:UIStatusBarStyleDefault];
  33. [alert setGesture:YES];
  34. [alert setConfirmBlock:confirmBlock];
  35. [alert setCancelBlock:cancleBlock];
  36. return alert;
  37. }
  38. -(IBAction)userDidBackClickAction:(id)sender{
  39. UIButton *btn = (id)sender;
  40. [self dismissWithAnimation:kAlertAnimationBottom];
  41. if(btn.tag == 11){
  42. //放弃
  43. if(self.cancelBlock){
  44. self.cancelBlock(ShowKeepNoticeCloseType1);
  45. }
  46. }else if (btn.tag == 12){
  47. //关闭
  48. if(self.cancelBlock){
  49. self.cancelBlock(ShowKeepNoticeCloseType2);
  50. }
  51. }
  52. }
  53. -(IBAction)userDidSureClickAction:(id)sender{
  54. [self dismissWithAnimation:kAlertAnimationBottom];
  55. if(self.confirmBlock){
  56. self.confirmBlock();
  57. }
  58. }
  59. @end