Skip to content

Commit

Permalink
整理QMUIAlertController代码
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoon committed Oct 31, 2017
1 parent 91381d7 commit 5efe07b
Showing 1 changed file with 4 additions and 27 deletions.
31 changes: 4 additions & 27 deletions QMUIKit/QMUIComponents/QMUIAlertController.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,6 @@ - (void)handleAlertActionEvent:(id)sender {
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickAlertAction:)]) {
[self.delegate didClickAlertAction:self];
}
// // 再调block回调
// if (self.handler) {
// self.handler(self);
// }
}

@end
Expand Down Expand Up @@ -725,9 +721,6 @@ - (void)customModalPresentationControllerAnimation {

self.modalPresentationViewController.showingAnimation = ^(UIView *dimmingView, CGRect containerBounds, CGFloat keyboardHeight, CGRect contentViewFrame, void(^completion)(BOOL finished)) {
if (self.preferredStyle == QMUIAlertControllerStyleAlert) {
// if ([weakSelf.delegate respondsToSelector:@selector(willShowAlertController:)]) {
// [weakSelf.delegate willShowAlertController:weakSelf];
// }
weakSelf.containerView.alpha = 0;
weakSelf.containerView.layer.transform = CATransform3DMakeScale(1.2, 1.2, 1.0);
[UIView animateWithDuration:0.25f delay:0 options:QMUIViewAnimationOptionsCurveOut animations:^{
Expand All @@ -736,26 +729,17 @@ - (void)customModalPresentationControllerAnimation {
weakSelf.containerView.layer.transform = CATransform3DMakeScale(1.0, 1.0, 1.0);
} completion:^(BOOL finished) {
weakSelf.isShowing = YES;
// if ([weakSelf.delegate respondsToSelector:@selector(didShowAlertController:)]) {
// [weakSelf.delegate didShowAlertController:weakSelf];
// }
if (completion) {
completion(finished);
}
}];
} else if (self.preferredStyle == QMUIAlertControllerStyleActionSheet) {
// if ([weakSelf.delegate respondsToSelector:@selector(willShowAlertController:)]) {
// [weakSelf.delegate willShowAlertController:weakSelf];
// }
weakSelf.containerView.layer.transform = CATransform3DMakeTranslation(0, CGRectGetHeight(weakSelf.containerView.bounds), 0);
[UIView animateWithDuration:0.25f delay:0 options:QMUIViewAnimationOptionsCurveOut animations:^{
weakSelf.maskView.alpha = 1;
weakSelf.containerView.layer.transform = CATransform3DIdentity;
} completion:^(BOOL finished) {
weakSelf.isShowing = YES;
// if ([weakSelf.delegate respondsToSelector:@selector(didShowAlertController:)]) {
// [weakSelf.delegate didShowAlertController:weakSelf];
// }
if (completion) {
completion(finished);
}
Expand All @@ -764,19 +748,13 @@ - (void)customModalPresentationControllerAnimation {
};

self.modalPresentationViewController.hidingAnimation = ^(UIView *dimmingView, CGRect containerBounds, CGFloat keyboardHeight, void(^completion)(BOOL finished)) {
// if ([weakSelf.delegate respondsToSelector:@selector(willHideAlertController:)]) {
// [weakSelf.delegate willHideAlertController:weakSelf];
// }
if (self.preferredStyle == QMUIAlertControllerStyleAlert) {
[UIView animateWithDuration:0.25f delay:0 options:QMUIViewAnimationOptionsCurveOut animations:^{
weakSelf.maskView.alpha = 0;
weakSelf.containerView.alpha = 0;
} completion:^(BOOL finished) {
weakSelf.isShowing = NO;
weakSelf.containerView.alpha = 1;
// if ([weakSelf.delegate respondsToSelector:@selector(didHideAlertController:)]) {
// [weakSelf.delegate didHideAlertController:weakSelf];
// }
if (completion) {
completion(finished);
}
Expand All @@ -787,9 +765,6 @@ - (void)customModalPresentationControllerAnimation {
weakSelf.containerView.layer.transform = CATransform3DMakeTranslation(0, CGRectGetHeight(weakSelf.containerView.bounds), 0);
} completion:^(BOOL finished) {
weakSelf.isShowing = NO;
// if ([weakSelf.delegate respondsToSelector:@selector(didHideAlertController:)]) {
// [weakSelf.delegate didHideAlertController:weakSelf];
// }
if (completion) {
completion(finished);
}
Expand Down Expand Up @@ -839,10 +814,12 @@ - (void)showWithAnimated:(BOOL)animated {
// 增加alertController计数
alertControllerCount++;
}
- (void)hideWithAnimated:(BOOL)animated{

- (void)hideWithAnimated:(BOOL)animated {
[self hideWithAnimated:animated completion:nil];
}
- (void)hideWithAnimated:(BOOL)animated completion:(void (^)(void))completion{

- (void)hideWithAnimated:(BOOL)animated completion:(void (^)(void))completion {
if (!self.isShowing) {
return;
}
Expand Down

0 comments on commit 5efe07b

Please sign in to comment.