@@ -180,7 +180,7 @@ @interface QMUIAlertController () <QMUIAlertActionDelegate, QMUIModalPresentatio
180180
181181@property (nonatomic , strong ) UIView *containerView;
182182
183- @property (nonatomic , strong ) UIControl *maskView ;
183+ @property (nonatomic , strong ) UIControl *dimmingView ;
184184
185185@property (nonatomic , strong ) UIView *scrollWrapView;
186186@property (nonatomic , strong ) UIScrollView *headerScrollView;
@@ -498,7 +498,7 @@ - (nonnull instancetype)initWithTitle:(nullable NSString *)title message:(nullab
498498
499499 self.preferredStyle = preferredStyle;
500500
501- self.shouldRespondMaskViewTouch = preferredStyle == QMUIAlertControllerStyleActionSheet;
501+ self.shouldRespondDimmingViewTouch = preferredStyle == QMUIAlertControllerStyleActionSheet;
502502
503503 self.alertActions = [[NSMutableArray alloc ] init ];
504504 self.alertTextFields = [[NSMutableArray alloc ] init ];
@@ -520,7 +520,7 @@ - (QMUIAlertControllerStyle)preferredStyle {
520520- (void )viewDidLoad {
521521 [super viewDidLoad ];
522522
523- [self .view addSubview: self .maskView ];
523+ [self .view addSubview: self .dimmingView ];
524524 [self .view addSubview: self .containerView];
525525 [self .containerView addSubview: self .scrollWrapView];
526526 [self .scrollWrapView addSubview: self .headerScrollView];
@@ -539,7 +539,7 @@ - (void)viewDidLayoutSubviews {
539539 BOOL shouldShowSeparatorAtTopOfButtonAtFirstLine = hasTitle || hasMessage || hasCustomView;
540540 CGFloat contentOriginY = 0 ;
541541
542- self.maskView .frame = self.view .bounds ;
542+ self.dimmingView .frame = self.view .bounds ;
543543
544544 if (self.preferredStyle == QMUIAlertControllerStyleAlert) {
545545
@@ -631,7 +631,7 @@ - (void)viewDidLayoutSubviews {
631631 self.buttonScrollView .contentSize = CGSizeMake (CGRectGetWidth (self.buttonScrollView .bounds ), contentOriginY);
632632 // 容器最后布局
633633 CGFloat contentHeight = CGRectGetHeight (self.headerScrollView .bounds ) + CGRectGetHeight (self.buttonScrollView .bounds );
634- CGFloat screenSpaceHeight = CGRectGetHeight (self.view .bounds ) - UIEdgeInsetsGetVerticalValue (SafeAreaInsetsConstantForDeviceWithNotch);
634+ CGFloat screenSpaceHeight = CGRectGetHeight (self.view .bounds ) - UIEdgeInsetsGetVerticalValue (SafeAreaInsetsConstantForDeviceWithNotch) - self. keyboardHeight ;
635635 if (contentHeight > screenSpaceHeight - 20 ) {
636636 screenSpaceHeight -= 20 ;
637637 CGFloat contentH = fmin (CGRectGetHeight (self.headerScrollView .bounds ), screenSpaceHeight / 2 );
@@ -655,7 +655,7 @@ - (void)viewDidLayoutSubviews {
655655 self.scrollWrapView .frame = CGRectMake (0 , 0 , CGRectGetWidth (self.scrollWrapView .bounds ), contentHeight);
656656 self.mainVisualEffectView .frame = self.scrollWrapView .bounds ;
657657
658- self.containerView .qmui_frameApplyTransform = CGRectMake ((CGRectGetWidth (self.view .bounds ) - CGRectGetWidth (self.containerView .frame )) / 2 , SafeAreaInsetsConstantForDeviceWithNotch.top + (screenSpaceHeight - contentHeight - self. keyboardHeight ) / 2 , CGRectGetWidth (self.containerView .frame ), CGRectGetHeight (self.scrollWrapView .bounds ));
658+ self.containerView .qmui_frameApplyTransform = CGRectMake ((CGRectGetWidth (self.view .bounds ) - CGRectGetWidth (self.containerView .frame )) / 2 , SafeAreaInsetsConstantForDeviceWithNotch.top + (screenSpaceHeight - contentHeight) / 2 , CGRectGetWidth (self.containerView .frame ), CGRectGetHeight (self.scrollWrapView .bounds ));
659659 }
660660
661661 else if (self.preferredStyle == QMUIAlertControllerStyleActionSheet) {
@@ -845,7 +845,7 @@ - (void)customModalPresentationControllerAnimation {
845845 weakSelf.containerView .alpha = 0 ;
846846 weakSelf.containerView .layer .transform = CATransform3DMakeScale (1.2 , 1.2 , 1.0 );
847847 [UIView animateWithDuration: 0 .25f delay: 0 options: QMUIViewAnimationOptionsCurveOut animations: ^{
848- weakSelf.maskView .alpha = 1 ;
848+ weakSelf.dimmingView .alpha = 1 ;
849849 weakSelf.containerView .alpha = 1 ;
850850 weakSelf.containerView .layer .transform = CATransform3DMakeScale (1.0 , 1.0 , 1.0 );
851851 } completion: ^(BOOL finished) {
@@ -856,7 +856,7 @@ - (void)customModalPresentationControllerAnimation {
856856 } else if (self.preferredStyle == QMUIAlertControllerStyleActionSheet) {
857857 weakSelf.containerView .layer .transform = CATransform3DMakeTranslation (0 , CGRectGetHeight (weakSelf.view .bounds ) - CGRectGetMinY (weakSelf.containerView .frame ), 0 );
858858 [UIView animateWithDuration: 0 .25f delay: 0 options: QMUIViewAnimationOptionsCurveOut animations: ^{
859- weakSelf.maskView .alpha = 1 ;
859+ weakSelf.dimmingView .alpha = 1 ;
860860 weakSelf.containerView .layer .transform = CATransform3DIdentity;
861861 } completion: ^(BOOL finished) {
862862 if (completion) {
@@ -869,7 +869,7 @@ - (void)customModalPresentationControllerAnimation {
869869 self.modalPresentationViewController .hidingAnimation = ^(UIView *dimmingView, CGRect containerBounds, CGFloat keyboardHeight, void (^completion)(BOOL finished)) {
870870 if (self.preferredStyle == QMUIAlertControllerStyleAlert) {
871871 [UIView animateWithDuration: 0 .25f delay: 0 options: QMUIViewAnimationOptionsCurveOut animations: ^{
872- weakSelf.maskView .alpha = 0 ;
872+ weakSelf.dimmingView .alpha = 0 ;
873873 weakSelf.containerView .alpha = 0 ;
874874 } completion: ^(BOOL finished) {
875875 weakSelf.containerView .alpha = 1 ;
@@ -879,7 +879,7 @@ - (void)customModalPresentationControllerAnimation {
879879 }];
880880 } else if (self.preferredStyle == QMUIAlertControllerStyleActionSheet) {
881881 [UIView animateWithDuration: 0 .25f delay: 0 options: QMUIViewAnimationOptionsCurveOut animations: ^{
882- weakSelf.maskView .alpha = 0 ;
882+ weakSelf.dimmingView .alpha = 0 ;
883883 weakSelf.containerView .layer .transform = CATransform3DMakeTranslation (0 , CGRectGetHeight (weakSelf.view .bounds ) - CGRectGetMinY (weakSelf.containerView .frame ), 0 );
884884 } completion: ^(BOOL finished) {
885885 if (completion) {
@@ -919,7 +919,7 @@ - (void)showWithAnimated:(BOOL)animated {
919919 __weak __typeof (self)weakSelf = self;
920920
921921 [self .modalPresentationViewController showWithAnimated: animated completion: ^(BOOL finished) {
922- weakSelf.maskView .alpha = 1 ;
922+ weakSelf.dimmingView .alpha = 1 ;
923923 weakSelf.willShow = NO ;
924924 weakSelf.showing = YES ;
925925 if (weakSelf.isNeedsHideAfterAlertShowed ) {
@@ -963,7 +963,7 @@ - (void)hideWithAnimated:(BOOL)animated completion:(void (^)(void))completion {
963963 weakSelf.modalPresentationViewController = nil ;
964964 weakSelf.willShow = NO ;
965965 weakSelf.showing = NO ;
966- weakSelf.maskView .alpha = 0 ;
966+ weakSelf.dimmingView .alpha = 0 ;
967967 if (self.preferredStyle == QMUIAlertControllerStyleAlert) {
968968 weakSelf.containerView .alpha = 0 ;
969969 } else {
@@ -1166,22 +1166,22 @@ - (void)updateAction {
11661166 return [self .alertTextFields copy ];
11671167}
11681168
1169- - (void )handleMaskViewEvent : (id )sender {
1170- if (_shouldRespondMaskViewTouch ) {
1169+ - (void )handleDimmingViewEvent : (id )sender {
1170+ if (_shouldRespondDimmingViewTouch ) {
11711171 [self hideWithAnimated: YES completion: NULL ];
11721172 }
11731173}
11741174
11751175#pragma mark - Getters & Setters
11761176
1177- - (UIControl *)maskView {
1178- if (!_maskView ) {
1179- _maskView = [[UIControl alloc ] init ];
1180- _maskView .alpha = 0 ;
1181- _maskView .backgroundColor = UIColorMask;
1182- [_maskView addTarget: self action: @selector (handleMaskViewEvent : ) forControlEvents: UIControlEventTouchUpInside];
1177+ - (UIControl *)dimmingView {
1178+ if (!_dimmingView ) {
1179+ _dimmingView = [[UIControl alloc ] init ];
1180+ _dimmingView .alpha = 0 ;
1181+ _dimmingView .backgroundColor = UIColorMask;
1182+ [_dimmingView addTarget: self action: @selector (handleDimmingViewEvent : ) forControlEvents: UIControlEventTouchUpInside];
11831183 }
1184- return _maskView ;
1184+ return _dimmingView ;
11851185}
11861186
11871187- (UIView *)containerView {
0 commit comments