SusBaseWindow.m 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // SusBaseWindow.m
  3. // BuguLive
  4. //
  5. // Created by 岳克奎 on 16/9/24.
  6. // Copyright © 2016年 xfg. All rights reserved.
  7. //
  8. #import "SusBaseWindow.h"
  9. @implementation SusBaseWindow
  10. - (id)initWithFrame:(CGRect)frame
  11. {
  12. self = [super initWithFrame:frame];
  13. if (self)
  14. {
  15. self.windowLevel = UIWindowLevelStatusBar - 2;
  16. [self addGesture];
  17. self.backgroundColor = [UIColor blackColor];
  18. }
  19. return self;
  20. }
  21. #pragma mark - 加手势
  22. - (void)addGesture
  23. {
  24. [self initTapGes];
  25. [self initPanGes];
  26. }
  27. #pragma amrk - Tap Ges
  28. - (void)initTapGes
  29. {
  30. _window_Tap_Ges = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapGesClick:)];
  31. [self addGestureRecognizer:_window_Tap_Ges];
  32. }
  33. - (void)tapGesClick:(UITapGestureRecognizer *)tap
  34. {
  35. [IQKeyboardManager sharedManager].enable = NO;
  36. [IQKeyboardManager sharedManager].enableAutoToolbar = NO;
  37. // 关闭键盘
  38. [BGUtils closeKeyboard];
  39. if ([IQKeyboardManager sharedManager].keyboardShowing)
  40. {
  41. [FanweMessage alert:ASLocalizedString(@"请先关闭键盘")];
  42. return;
  43. }
  44. if (SUS_WINDOW.reccordSusWidnowSale)
  45. {
  46. //tap
  47. if (_susBaseWindowTapGesBlock)
  48. {
  49. _susBaseWindowTapGesBlock();
  50. }
  51. }
  52. }
  53. #pragma mark - Pan Ges
  54. - (void)initPanGes
  55. {
  56. _window_Pan_Ges =[[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(panGesClick:)];
  57. _window_Pan_Ges.delaysTouchesBegan = NO;
  58. [self addGestureRecognizer:_window_Pan_Ges];
  59. }
  60. - (void)panGesClick:(UIPanGestureRecognizer *)pan
  61. {
  62. if (SUS_WINDOW.reccordSusWidnowSale)
  63. {
  64. if (_susBaseWindowPanGesBlock)
  65. {
  66. _susBaseWindowPanGesBlock();
  67. }
  68. }
  69. }
  70. #pragma mark- window 剪切 下角
  71. - (void)setWindowCorner
  72. {
  73. self.layer.cornerRadius = 8;
  74. self.layer.masksToBounds = YES;
  75. }
  76. - (void)setIsSusWindow:(BOOL)isSusWindow
  77. {
  78. _isSusWindow = isSusWindow;
  79. }
  80. @end