@@ -180,7 +180,7 @@ @interface QMUIAlertController () <QMUIAlertActionDelegate, QMUIModalPresentatio
180
180
181
181
@property (nonatomic , strong ) UIView *containerView;
182
182
183
- @property (nonatomic , strong ) UIControl *maskView ;
183
+ @property (nonatomic , strong ) UIControl *dimmingView ;
184
184
185
185
@property (nonatomic , strong ) UIView *scrollWrapView;
186
186
@property (nonatomic , strong ) UIScrollView *headerScrollView;
@@ -498,7 +498,7 @@ - (nonnull instancetype)initWithTitle:(nullable NSString *)title message:(nullab
498
498
499
499
self.preferredStyle = preferredStyle;
500
500
501
- self.shouldRespondMaskViewTouch = preferredStyle == QMUIAlertControllerStyleActionSheet;
501
+ self.shouldRespondDimmingViewTouch = preferredStyle == QMUIAlertControllerStyleActionSheet;
502
502
503
503
self.alertActions = [[NSMutableArray alloc ] init ];
504
504
self.alertTextFields = [[NSMutableArray alloc ] init ];
@@ -520,7 +520,7 @@ - (QMUIAlertControllerStyle)preferredStyle {
520
520
- (void )viewDidLoad {
521
521
[super viewDidLoad ];
522
522
523
- [self .view addSubview: self .maskView ];
523
+ [self .view addSubview: self .dimmingView ];
524
524
[self .view addSubview: self .containerView];
525
525
[self .containerView addSubview: self .scrollWrapView];
526
526
[self .scrollWrapView addSubview: self .headerScrollView];
@@ -539,7 +539,7 @@ - (void)viewDidLayoutSubviews {
539
539
BOOL shouldShowSeparatorAtTopOfButtonAtFirstLine = hasTitle || hasMessage || hasCustomView;
540
540
CGFloat contentOriginY = 0 ;
541
541
542
- self.maskView .frame = self.view .bounds ;
542
+ self.dimmingView .frame = self.view .bounds ;
543
543
544
544
if (self.preferredStyle == QMUIAlertControllerStyleAlert) {
545
545
@@ -631,7 +631,7 @@ - (void)viewDidLayoutSubviews {
631
631
self.buttonScrollView .contentSize = CGSizeMake (CGRectGetWidth (self.buttonScrollView .bounds ), contentOriginY);
632
632
// 容器最后布局
633
633
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 ;
635
635
if (contentHeight > screenSpaceHeight - 20 ) {
636
636
screenSpaceHeight -= 20 ;
637
637
CGFloat contentH = fmin (CGRectGetHeight (self.headerScrollView .bounds ), screenSpaceHeight / 2 );
@@ -655,7 +655,7 @@ - (void)viewDidLayoutSubviews {
655
655
self.scrollWrapView .frame = CGRectMake (0 , 0 , CGRectGetWidth (self.scrollWrapView .bounds ), contentHeight);
656
656
self.mainVisualEffectView .frame = self.scrollWrapView .bounds ;
657
657
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 ));
659
659
}
660
660
661
661
else if (self.preferredStyle == QMUIAlertControllerStyleActionSheet) {
@@ -845,7 +845,7 @@ - (void)customModalPresentationControllerAnimation {
845
845
weakSelf.containerView .alpha = 0 ;
846
846
weakSelf.containerView .layer .transform = CATransform3DMakeScale (1.2 , 1.2 , 1.0 );
847
847
[UIView animateWithDuration: 0 .25f delay: 0 options: QMUIViewAnimationOptionsCurveOut animations: ^{
848
- weakSelf.maskView .alpha = 1 ;
848
+ weakSelf.dimmingView .alpha = 1 ;
849
849
weakSelf.containerView .alpha = 1 ;
850
850
weakSelf.containerView .layer .transform = CATransform3DMakeScale (1.0 , 1.0 , 1.0 );
851
851
} completion: ^(BOOL finished) {
@@ -856,7 +856,7 @@ - (void)customModalPresentationControllerAnimation {
856
856
} else if (self.preferredStyle == QMUIAlertControllerStyleActionSheet) {
857
857
weakSelf.containerView .layer .transform = CATransform3DMakeTranslation (0 , CGRectGetHeight (weakSelf.view .bounds ) - CGRectGetMinY (weakSelf.containerView .frame ), 0 );
858
858
[UIView animateWithDuration: 0 .25f delay: 0 options: QMUIViewAnimationOptionsCurveOut animations: ^{
859
- weakSelf.maskView .alpha = 1 ;
859
+ weakSelf.dimmingView .alpha = 1 ;
860
860
weakSelf.containerView .layer .transform = CATransform3DIdentity;
861
861
} completion: ^(BOOL finished) {
862
862
if (completion) {
@@ -869,7 +869,7 @@ - (void)customModalPresentationControllerAnimation {
869
869
self.modalPresentationViewController .hidingAnimation = ^(UIView *dimmingView, CGRect containerBounds, CGFloat keyboardHeight, void (^completion)(BOOL finished)) {
870
870
if (self.preferredStyle == QMUIAlertControllerStyleAlert) {
871
871
[UIView animateWithDuration: 0 .25f delay: 0 options: QMUIViewAnimationOptionsCurveOut animations: ^{
872
- weakSelf.maskView .alpha = 0 ;
872
+ weakSelf.dimmingView .alpha = 0 ;
873
873
weakSelf.containerView .alpha = 0 ;
874
874
} completion: ^(BOOL finished) {
875
875
weakSelf.containerView .alpha = 1 ;
@@ -879,7 +879,7 @@ - (void)customModalPresentationControllerAnimation {
879
879
}];
880
880
} else if (self.preferredStyle == QMUIAlertControllerStyleActionSheet) {
881
881
[UIView animateWithDuration: 0 .25f delay: 0 options: QMUIViewAnimationOptionsCurveOut animations: ^{
882
- weakSelf.maskView .alpha = 0 ;
882
+ weakSelf.dimmingView .alpha = 0 ;
883
883
weakSelf.containerView .layer .transform = CATransform3DMakeTranslation (0 , CGRectGetHeight (weakSelf.view .bounds ) - CGRectGetMinY (weakSelf.containerView .frame ), 0 );
884
884
} completion: ^(BOOL finished) {
885
885
if (completion) {
@@ -919,7 +919,7 @@ - (void)showWithAnimated:(BOOL)animated {
919
919
__weak __typeof (self)weakSelf = self;
920
920
921
921
[self .modalPresentationViewController showWithAnimated: animated completion: ^(BOOL finished) {
922
- weakSelf.maskView .alpha = 1 ;
922
+ weakSelf.dimmingView .alpha = 1 ;
923
923
weakSelf.willShow = NO ;
924
924
weakSelf.showing = YES ;
925
925
if (weakSelf.isNeedsHideAfterAlertShowed ) {
@@ -963,7 +963,7 @@ - (void)hideWithAnimated:(BOOL)animated completion:(void (^)(void))completion {
963
963
weakSelf.modalPresentationViewController = nil ;
964
964
weakSelf.willShow = NO ;
965
965
weakSelf.showing = NO ;
966
- weakSelf.maskView .alpha = 0 ;
966
+ weakSelf.dimmingView .alpha = 0 ;
967
967
if (self.preferredStyle == QMUIAlertControllerStyleAlert) {
968
968
weakSelf.containerView .alpha = 0 ;
969
969
} else {
@@ -1166,22 +1166,22 @@ - (void)updateAction {
1166
1166
return [self .alertTextFields copy ];
1167
1167
}
1168
1168
1169
- - (void )handleMaskViewEvent : (id )sender {
1170
- if (_shouldRespondMaskViewTouch ) {
1169
+ - (void )handleDimmingViewEvent : (id )sender {
1170
+ if (_shouldRespondDimmingViewTouch ) {
1171
1171
[self hideWithAnimated: YES completion: NULL ];
1172
1172
}
1173
1173
}
1174
1174
1175
1175
#pragma mark - Getters & Setters
1176
1176
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];
1183
1183
}
1184
- return _maskView ;
1184
+ return _dimmingView ;
1185
1185
}
1186
1186
1187
1187
- (UIView *)containerView {
0 commit comments