RAPopviewContainer.m 2.2 KB

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