diff --git a/SCLAlertView/SCLAlertView.h b/SCLAlertView/SCLAlertView.h index e3c88da..2614f3f 100755 --- a/SCLAlertView/SCLAlertView.h +++ b/SCLAlertView/SCLAlertView.h @@ -17,6 +17,7 @@ typedef NSAttributedString* (^SCLAttributedFormatBlock)(NSString *value); typedef void (^SCLDismissBlock)(void); +typedef void (^SCLDismissAnimationCompletionBlock)(void); typedef void (^SCLForceHideBlock)(void); @interface SCLAlertView : UIViewController @@ -246,10 +247,17 @@ typedef NS_ENUM(NSInteger, SCLAlertViewBackground) */ - (void)alertIsDismissed:(SCLDismissBlock)dismissBlock; +/** Warns that alerts dismiss animation is completed + * + * Warns that alerts dismiss animation is completed + */ +- (void)alertDismissAnimationIsCompleted:(SCLDismissAnimationCompletionBlock)dismissAnimationCompletionBlock; + /** Hide SCLAlertView * * Hide SCLAlertView using animation and removing from super view. */ + - (void)hideView; /** SCLAlertView visibility @@ -542,6 +550,7 @@ typedef NS_ENUM(NSInteger, SCLAlertViewBackground) #pragma mark - Custom Setters @property(copy, nonatomic) SCLAlertViewBuilder *(^alertIsDismissed) (SCLDismissBlock dismissBlock); +@property(copy, nonatomic) SCLAlertViewBuilder *(^alertDismissAnimationIsCompleted) (SCLDismissAnimationCompletionBlock dismissAnimationCompletionBlock); @property(copy, nonatomic) SCLAlertViewBuilder *(^removeTopCircle)(void); @property(copy, nonatomic) SCLAlertViewBuilder *(^addCustomView)(UIView *view); @property(copy, nonatomic) SCLAlertViewBuilder *(^addTextField)(NSString *title); diff --git a/SCLAlertView/SCLAlertView.m b/SCLAlertView/SCLAlertView.m index 8b7f9a2..8104ccb 100755 --- a/SCLAlertView/SCLAlertView.m +++ b/SCLAlertView/SCLAlertView.m @@ -43,6 +43,7 @@ @interface SCLAlertView () @property (strong, nonatomic) UIWindow *previousWindow; @property (strong, nonatomic) UIWindow *SCLAlertWindow; @property (copy, nonatomic) SCLDismissBlock dismissBlock; +@property (copy, nonatomic) SCLDismissAnimationCompletionBlock dismissAnimationCompletionBlock; @property (weak, nonatomic) UIViewController *rootViewController; @property (weak, nonatomic) id restoreInteractivePopGestureDelegate; @property (assign, nonatomic) SystemSoundID soundID; @@ -1170,6 +1171,10 @@ - (void)alertIsDismissed:(SCLDismissBlock)dismissBlock self.dismissBlock = dismissBlock; } +- (void)alertDismissAnimationIsCompleted:(SCLDismissAnimationCompletionBlock)dismissAnimationCompletionBlock{ + self.dismissAnimationCompletionBlock = dismissAnimationCompletionBlock; +} + - (SCLForceHideBlock)forceHideBlock:(SCLForceHideBlock)forceHideBlock { _forceHideBlock = forceHideBlock; @@ -1376,6 +1381,9 @@ - (void)fadeOutWithDuration:(NSTimeInterval)duration [self.view removeFromSuperview]; [self removeFromParentViewController]; } + if ( _dismissAnimationCompletionBlock ){ + self.dismissAnimationCompletionBlock(); + } }]; } @@ -2011,6 +2019,16 @@ - (instancetype)initWithNewWindowWidth:(CGFloat)width { } return _alertIsDismissed; } +-(SCLAlertViewBuilder *(^)(SCLDismissAnimationCompletionBlock))alertDismissAnimationIsCompleted{ + if (!_alertDismissAnimationIsCompleted) { + __weak typeof(self) weakSelf = self; + _alertDismissAnimationIsCompleted = ^(SCLDismissAnimationCompletionBlock dismissAnimationCompletionBlock) { + [weakSelf.alertView alertDismissAnimationIsCompleted:dismissAnimationCompletionBlock]; + return weakSelf; + }; + } + return _alertDismissAnimationIsCompleted; +} - (SCLAlertViewBuilder *(^) (void))removeTopCircle { if (!_removeTopCircle) { __weak typeof(self) weakSelf = self;