STSuspensionWindow.m 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. //
  2. // STSuspensionWindow.m
  3. // BuguLive
  4. //
  5. // Created by 岳克奎 on 17/1/18.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "STSuspensionWindow.h"
  9. @implementation STSuspensionWindow
  10. //new STBaseSuspensionWindow
  11. + (STSuspensionWindow *)showWindowTypeOfSTBaseSuspensionWindowOfFrameRect:(CGRect)frameRect
  12. ofSTBaseSuspensionWindowLevelValue:(CGFloat)stSuspensionWindowLevelValue
  13. complete:(void(^)(BOOL finished,
  14. STSuspensionWindow *stSuspensionWindow))block
  15. {
  16. //
  17. STSuspensionWindow *stSuspensionWindow = [[STSuspensionWindow alloc]initWithFrame:frameRect];
  18. //
  19. stSuspensionWindow.windowLevel = stSuspensionWindowLevelValue;
  20. //
  21. //[stSuspensionWindow makeKeyWindow];
  22. //
  23. stSuspensionWindow.hidden = YES;
  24. //test
  25. stSuspensionWindow.backgroundColor = [UIColor redColor];
  26. if (block)
  27. {
  28. block(YES,stSuspensionWindow);
  29. }
  30. return stSuspensionWindow;
  31. }
  32. //控制 widnow的显示 前提存在window
  33. - (void)setStSusWindowShowState:(STSusWindowShowState )stSusWindowShowState
  34. {
  35. _stSusWindowShowState = stSusWindowShowState;
  36. if(stSusWindowShowState == stSusWindowShowYES)
  37. {
  38. [self makeKeyWindow];
  39. self.hidden = NO;
  40. }
  41. else
  42. {
  43. [self resignKeyWindow];
  44. self.hidden = YES;
  45. }
  46. }
  47. #pragma mark ------------------------------------------- private methods
  48. #pragma mark - 重写手势方法
  49. /**
  50. tap子重写
  51. @param tapGestureRecognizer 放大
  52. */
  53. - (void)tapGestureRecognizerClick:(UITapGestureRecognizer *)tapGestureRecognizer
  54. {
  55. //回调调度中心
  56. // [ST_LIVE_CENTER_MANAGER setStSusAnimationType:stSusAnimationTypeOfFull];
  57. }
  58. //tap 子重写
  59. - (void)panGestureRecognizerClick:(UIPanGestureRecognizer *)panGestureRecognizer
  60. {
  61. [self showPanClickForSTWindowOfPoint:[self.panGestureRecognizer locationInView:self] andMovePoint:[self.panGestureRecognizer translationInView: self]];
  62. }
  63. /**
  64. *
  65. * @brief:悬浮动画(缩放)
  66. *
  67. *@prama : stSusAnimationType 动画类型 small+full
  68. *@prama : stLiveModel
  69. *@prama : liveViewC 需要处理 关闭btn,liveView,liveViewC
  70. *@prama : stSuspensionWindow 处理尺寸问题
  71. *
  72. *
  73. *@discussion: 1. 能进来说明必定是悬浮类
  74. * 2. 动画需要 拿到ViewC
  75. *
  76. *@attention :
  77. *
  78. *@return : BOOL YES动画加载成功 NO 未启动动画
  79. *
  80. */
  81. //+ (void)showSTSusAnimationType:(LiveWindowType)liveWindowType
  82. // andSTLiveType:(FW_LIVE_TYPE )liveType
  83. // andLivewViewC:(UIViewController *)liveViewC
  84. // andSTSuspensionWindow:(STSuspensionWindow *)stSuspensionWindow
  85. // complete:(void(^)(BOOL finished))block{
  86. //
  87. // BGTLiveController *fwTLiveController;
  88. // FWHDLiveController *fwHDLiveController;
  89. // UIButton *closeBtn;
  90. // UIView *liveView;
  91. // //互动
  92. // if (stLiveType == stLiveTypeOfHDHost||stLiveType == stLiveTypeOfHDAudience) {
  93. // fwHDLiveController = (FWHDLiveController *) liveViewC;
  94. // closeBtn = fwHDLiveController.liveServiceController.closeBtn;
  95. // liveView= fwHDLiveController.liveServiceController.liveUIViewController.liveView;
  96. // }
  97. // //云
  98. // if(stLiveType== stLiveTypeOfYunHost ||stLiveType == stLiveTypeOfYunPlayback ||stLiveType == stLiveTypeOfYunAudience){
  99. // fwTLiveController =(BGTLiveController *)liveViewC;
  100. // closeBtn = fwTLiveController.liveServiceController.closeBtn;
  101. // liveView= fwTLiveController.liveServiceController.liveUIViewController.liveView;
  102. //
  103. // }
  104. // if (stSusAnimationType == stSusAnimationTypeOfSmall) {
  105. // liveView.hidden = YES;
  106. // stSuspensionWindow.transform = CGAffineTransformMakeScale(0.4, 0.6*kScreenW/kScreenH);
  107. // stSuspensionWindow.tapGestureRecognizer.enabled = YES;
  108. // stSuspensionWindow.panGestureRecognizer.enabled = YES;
  109. // fwTLiveController.liveServiceController.liveUIViewController.panGestureRec.enabled = NO;
  110. //
  111. //
  112. // }
  113. // if (stSusAnimationType == stSusAnimationTypeOfFull) {
  114. // stSuspensionWindow.transform = CGAffineTransformIdentity;
  115. // stSuspensionWindow.tapGestureRecognizer.enabled = NO;
  116. // stSuspensionWindow.panGestureRecognizer.enabled = NO;
  117. // liveView.hidden = NO;
  118. // fwTLiveController.liveServiceController.liveUIViewController.panGestureRec.enabled = YES;
  119. // stSuspensionWindow.frame = CGRectMake(0, 0, kScreenW, kScreenH);
  120. // }
  121. //
  122. // if (block) {
  123. // block(YES);
  124. // }
  125. //
  126. //}
  127. - (void)setIsSmallSize:(BOOL)isSmallSize
  128. {
  129. if (_isSmallSize == isSmallSize)
  130. {
  131. }
  132. else
  133. {
  134. if (isSmallSize)
  135. {
  136. //缩小
  137. self.transform = CGAffineTransformMakeScale(0.4, 0.6*kScreenW/kScreenH);
  138. self.tapGestureRecognizer.enabled = YES;
  139. self.panGestureRecognizer.enabled = YES;
  140. }
  141. else
  142. {
  143. //如果悬浮放大
  144. self.transform = CGAffineTransformIdentity;
  145. self.tapGestureRecognizer.enabled = NO;
  146. self.panGestureRecognizer.enabled = NO;
  147. }
  148. if (_delegate && [_delegate respondsToSelector:@selector(showAnimationComplete:)])
  149. {
  150. [_delegate showAnimationComplete:^(BOOL finished) {
  151. //带block 万一传2个以上参数呢,,
  152. _isSmallSize = isSmallSize;
  153. }];
  154. }
  155. }
  156. //满屏处理完毕
  157. if (!_isSmallSize&& _delegate &&[_delegate respondsToSelector:@selector(showFullScreenFinished:)])
  158. {
  159. [_delegate showFullScreenFinished:^(BOOL finished) {
  160. }];
  161. }
  162. }
  163. @end