HWPanModalPresentationController+RQExtension.m 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // HWPanModalPresentationController+RQExtension.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2022/4/20.
  6. // Copyright © 2022 JCZ. All rights reserved.
  7. //
  8. #import "HWPanModalPresentationController+RQExtension.h"
  9. @interface HWPanModalPresentationController (RQExtension)
  10. @end
  11. @implementation HWPanModalPresentationController (RQExtension)
  12. - (void)adjustPresentedViewFrame {
  13. if (!self.containerView)
  14. return;
  15. CGRect frame = self.containerView.frame;
  16. CGSize size = CGSizeMake(CGRectGetWidth(frame), CGRectGetHeight(frame) - self.handler.anchoredYPosition);
  17. self.presentedView.hw_size = frame.size;
  18. if ([self.dragIndicatorView isKindOfClass:[RQHeadImageView class]]) {
  19. RQHeadImageView *myheadImageView = self.dragIndicatorView;
  20. self.panContainerView.contentView.frame = CGRectMake(0, myheadImageView.isCustomIndicatorViewClickEnable? [self.dragIndicatorView indicatorSize].height + kIndicatorYOffset : 0, size.width, size.height);
  21. } else {
  22. self.panContainerView.contentView.frame = CGRectMake(0, 0, size.width, size.height);
  23. }
  24. self.presentedViewController.view.frame = self.panContainerView.contentView.bounds;
  25. [self.presentedViewController.view setNeedsLayout];
  26. [self.presentedViewController.view layoutIfNeeded];
  27. }
  28. - (void)addDragIndicatorViewToView:(UIView *)view {
  29. // if has been add, won't update it.
  30. self.dragIndicatorView.hidden = NO;
  31. CGSize indicatorSize = [self.dragIndicatorView indicatorSize];
  32. if (self.dragIndicatorView.superview == view) {
  33. self.dragIndicatorView.frame = CGRectMake((view.hw_width - indicatorSize.width) / 2, -kIndicatorYOffset - indicatorSize.height, indicatorSize.width, indicatorSize.height);
  34. [self.dragIndicatorView didChangeToState:HWIndicatorStateNormal];
  35. return;
  36. }
  37. self.handler.dragIndicatorView = self.dragIndicatorView;
  38. [view addSubview:self.dragIndicatorView];
  39. if ([self.dragIndicatorView isKindOfClass:[RQHeadImageView class]]) {
  40. RQHeadImageView *myheadImageView = self.dragIndicatorView;
  41. self.dragIndicatorView.frame = CGRectMake((view.hw_width - indicatorSize.width) / 2, myheadImageView.isCustomIndicatorViewClickEnable? 0 : -kIndicatorYOffset - indicatorSize.height, indicatorSize.width, indicatorSize.height);
  42. } else {
  43. self.dragIndicatorView.frame = CGRectMake((view.hw_width - indicatorSize.width) / 2, -kIndicatorYOffset - indicatorSize.height, indicatorSize.width, indicatorSize.height);
  44. }
  45. [self.dragIndicatorView setupSubviews];
  46. [self.dragIndicatorView didChangeToState:HWIndicatorStateNormal];
  47. }
  48. @end