// // HWPanModalPresentationController+RQExtension.m // jiaPei // // Created by 张嵘 on 2022/4/20. // Copyright © 2022 JCZ. All rights reserved. // #import "HWPanModalPresentationController+RQExtension.h" @interface HWPanModalPresentationController (RQExtension) @end @implementation HWPanModalPresentationController (RQExtension) - (void)adjustPresentedViewFrame { if (!self.containerView) return; CGRect frame = self.containerView.frame; CGSize size = CGSizeMake(CGRectGetWidth(frame), CGRectGetHeight(frame) - self.handler.anchoredYPosition); self.presentedView.hw_size = frame.size; if ([self.dragIndicatorView isKindOfClass:[RQHeadImageView class]]) { RQHeadImageView *myheadImageView = self.dragIndicatorView; self.panContainerView.contentView.frame = CGRectMake(0, myheadImageView.isCustomIndicatorViewClickEnable? [self.dragIndicatorView indicatorSize].height + kIndicatorYOffset : 0, size.width, size.height); } else { self.panContainerView.contentView.frame = CGRectMake(0, 0, size.width, size.height); } self.presentedViewController.view.frame = self.panContainerView.contentView.bounds; [self.presentedViewController.view setNeedsLayout]; [self.presentedViewController.view layoutIfNeeded]; } - (void)addDragIndicatorViewToView:(UIView *)view { // if has been add, won't update it. self.dragIndicatorView.hidden = NO; CGSize indicatorSize = [self.dragIndicatorView indicatorSize]; if (self.dragIndicatorView.superview == view) { self.dragIndicatorView.frame = CGRectMake((view.hw_width - indicatorSize.width) / 2, -kIndicatorYOffset - indicatorSize.height, indicatorSize.width, indicatorSize.height); [self.dragIndicatorView didChangeToState:HWIndicatorStateNormal]; return; } self.handler.dragIndicatorView = self.dragIndicatorView; [view addSubview:self.dragIndicatorView]; if ([self.dragIndicatorView isKindOfClass:[RQHeadImageView class]]) { RQHeadImageView *myheadImageView = self.dragIndicatorView; self.dragIndicatorView.frame = CGRectMake((view.hw_width - indicatorSize.width) / 2, myheadImageView.isCustomIndicatorViewClickEnable? 0 : -kIndicatorYOffset - indicatorSize.height, indicatorSize.width, indicatorSize.height); } else { self.dragIndicatorView.frame = CGRectMake((view.hw_width - indicatorSize.width) / 2, -kIndicatorYOffset - indicatorSize.height, indicatorSize.width, indicatorSize.height); } [self.dragIndicatorView setupSubviews]; [self.dragIndicatorView didChangeToState:HWIndicatorStateNormal]; } @end