RAPopviewContainer.m 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. //
  2. // KKPopupViewWrapper.m
  3. // KKTV
  4. //
  5. // Created by yangyi on 2018/7/6.
  6. //
  7. #import "RAPopviewContainer.h"
  8. #import "const.h"
  9. #import "RAUtils.h"
  10. @protocol RAPopviewContainerProtocol <NSObject>
  11. @property (nonatomic, weak) RAPopviewContainer *container;
  12. @end
  13. @implementation RAPopviewContainer
  14. {
  15. id<RAPopviewProtocol> _popupView;
  16. }
  17. - (instancetype)initWithView:(id<RAPopviewProtocol>)popupView
  18. {
  19. if (self = [super init]) {
  20. _popupView = popupView;
  21. ((id<RAPopviewContainerProtocol>)_popupView).container = self;
  22. }
  23. return self;
  24. }
  25. - (UIView *)show:(UIView*)parentView
  26. {
  27. // [parentView setClipsToBounds:false];
  28. UIView *view = [_popupView show:parentView];
  29. if (self.bgColor) self.backgroundColor = self.bgColor;
  30. // return [PopWaitAlert Show: title:title message:@"Please wait..." completion:nil];
  31. // ;
  32. // CGRect r1 =[UIApplication sharedApplication].keyWindow.bounds;
  33. // CGRect r2 =[UIApplication sharedApplication].keyWindow.rootViewController.view.bounds;
  34. self.frame = [RAUtils keyWindow].bounds;//parentView.bounds;
  35. [self addTarget:self action:@selector(onBkgButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
  36. // [[UIApplication sharedApplication].keyWindow
  37. // [[UIApplication sharedApplication].keyWindow addSubview:view];
  38. [parentView insertSubview:self belowSubview:view];
  39. return nil;
  40. }
  41. - (void)hide
  42. {
  43. if (self.hideHandler)
  44. self.hideHandler();
  45. DebugLog(@"hide...");
  46. [self removeFromSuperview];
  47. }
  48. - (void)onBkgButtonClicked:(id)sender
  49. {
  50. if(self.modalView)
  51. return;
  52. [_popupView hide];
  53. }
  54. @end
  55. @interface RAPopView () <RAPopviewContainerProtocol>
  56. @end
  57. @implementation RAPopView
  58. @synthesize container;
  59. - (UIView*)show:(UIView *)parentView
  60. {
  61. [parentView addSubview:self];
  62. return self;
  63. }
  64. - (void)hide
  65. {
  66. [self removeFromSuperview];
  67. [self.container hide];
  68. }
  69. @end
  70. ////
  71. ////@interface KKPopupObject () <KKPopupViewWrapperProtocol>
  72. ////
  73. ////@end
  74. ////
  75. ////@implementation KKPopupObject
  76. ////
  77. ////@synthesize wrapper;
  78. ////
  79. ////- (UIView *)show:(UIView *)parentView
  80. ////{
  81. //// return nil;
  82. ////}
  83. ////
  84. ////- (void)hide
  85. ////{
  86. //// [self.wrapper hide];
  87. ////}
  88. //
  89. //@end