From c033fbe71f27798ea75ebada62ed6192392432d1 Mon Sep 17 00:00:00 2001 From: Grigory Lutkov Date: Sat, 7 Nov 2015 17:32:20 +0300 Subject: [PATCH] Added ability to transition between alert views --- Demo/LGAlertViewDemo/LaunchScreen.storyboard | 7 +- Demo/LGAlertViewDemo/TableViewController.m | 4 +- .../TableViewControllerActionSheet.m | 31 ++- .../TableViewControllerAlert.m | 31 ++- Demo/Podfile.lock | 4 +- LGAlertView.podspec | 2 +- LGAlertView/LGAlertView.h | 2 + LGAlertView/LGAlertView.m | 195 ++++++++++++++---- 8 files changed, 229 insertions(+), 47 deletions(-) diff --git a/Demo/LGAlertViewDemo/LaunchScreen.storyboard b/Demo/LGAlertViewDemo/LaunchScreen.storyboard index 4bd95a5..0769c0b 100644 --- a/Demo/LGAlertViewDemo/LaunchScreen.storyboard +++ b/Demo/LGAlertViewDemo/LaunchScreen.storyboard @@ -1,8 +1,8 @@ - + - + @@ -20,17 +20,20 @@ + diff --git a/Demo/LGAlertViewDemo/TableViewController.m b/Demo/LGAlertViewDemo/TableViewController.m index e8df175..54517f9 100644 --- a/Demo/LGAlertViewDemo/TableViewController.m +++ b/Demo/LGAlertViewDemo/TableViewController.m @@ -33,6 +33,8 @@ - (id)init @"Custom ActionSheet Styles"]; [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"]; + + self.clearsSelectionOnViewWillAppear = YES; } return self; } @@ -90,8 +92,6 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath TableViewControllerCustomActionSheet *tableViewController = [TableViewControllerCustomActionSheet new]; [self.navigationController pushViewController:tableViewController animated:YES]; } - - [tableView deselectRowAtIndexPath:indexPath animated:YES]; } @end diff --git a/Demo/LGAlertViewDemo/TableViewControllerActionSheet.m b/Demo/LGAlertViewDemo/TableViewControllerActionSheet.m index ef7d16a..f5e04d1 100644 --- a/Demo/LGAlertViewDemo/TableViewControllerActionSheet.m +++ b/Demo/LGAlertViewDemo/TableViewControllerActionSheet.m @@ -36,7 +36,8 @@ - (id)init @"LGAlertView + UIView", @"LGAlertView + ActivityIndicator", @"LGAlertView + ActivityIndicator cancel", - @"LGAlertView + ProgressView cancel"]; + @"LGAlertView + ProgressView cancel", + @"LGAlertView + Transition"]; [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"]; UIEdgeInsets contentInset = self.tableView.contentInset; @@ -308,6 +309,34 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath [self updateProgressWithAlertView:alertView]; } + else if (indexPath.row == 13) + { + LGAlertView *alertView1 = [[LGAlertView alloc] initWithActivityIndicatorAndTitle:@"Loading" + message:@"Waiting please" + style:LGAlertViewStyleActionSheet + buttonTitles:nil + cancelButtonTitle:@"I'm hurry" + destructiveButtonTitle:nil + actionHandler:nil + cancelHandler:nil + destructiveHandler:nil]; + [alertView1 showAnimated:YES completionHandler:nil]; + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^(void) + { + LGAlertView *alertView2 = [[LGAlertView alloc] initWithTitle:@"Title" + message:@"Message" + style:LGAlertViewStyleAlert + buttonTitles:@[@"Button 1", @"Button 2"] + cancelButtonTitle:@"Cancel" + destructiveButtonTitle:@"Destructive" + actionHandler:nil + cancelHandler:nil + destructiveHandler:nil]; + + [alertView1 transitionToAlertView:alertView2 completionHandler:nil]; + }); + } [tableView deselectRowAtIndexPath:indexPath animated:YES]; } diff --git a/Demo/LGAlertViewDemo/TableViewControllerAlert.m b/Demo/LGAlertViewDemo/TableViewControllerAlert.m index 9eade4c..44fcaaa 100644 --- a/Demo/LGAlertViewDemo/TableViewControllerAlert.m +++ b/Demo/LGAlertViewDemo/TableViewControllerAlert.m @@ -42,7 +42,8 @@ - (id)init @"LGAlertView + UIView", @"LGAlertView + ActivityIndicator", @"LGAlertView + ActivityIndicator cancel", - @"LGAlertView + ProgressView cancel"]; + @"LGAlertView + ProgressView cancel", + @"LGAlertView + Transition"]; [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"]; UIEdgeInsets contentInset = self.tableView.contentInset; @@ -398,6 +399,34 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath [self updateProgressWithAlertView:alertView]; } + else if (indexPath.row == 18) + { + LGAlertView *alertView1 = [[LGAlertView alloc] initWithActivityIndicatorAndTitle:@"Loading" + message:@"Waiting please" + style:LGAlertViewStyleAlert + buttonTitles:nil + cancelButtonTitle:@"I'm hurry" + destructiveButtonTitle:nil + actionHandler:nil + cancelHandler:nil + destructiveHandler:nil]; + [alertView1 showAnimated:YES completionHandler:nil]; + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^(void) + { + LGAlertView *alertView2 = [[LGAlertView alloc] initWithTitle:@"Title" + message:@"Message" + style:LGAlertViewStyleActionSheet + buttonTitles:@[@"Button 1", @"Button 2"] + cancelButtonTitle:@"Cancel" + destructiveButtonTitle:@"Destructive" + actionHandler:nil + cancelHandler:nil + destructiveHandler:nil]; + + [alertView1 transitionToAlertView:alertView2 completionHandler:nil]; + }); + } [tableView deselectRowAtIndexPath:indexPath animated:YES]; } diff --git a/Demo/Podfile.lock b/Demo/Podfile.lock index 0e2a82e..4dcda5b 100644 --- a/Demo/Podfile.lock +++ b/Demo/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - LGAlertView (2.0.0) + - LGAlertView (2.0.2) DEPENDENCIES: - LGAlertView (from `../`) @@ -9,6 +9,6 @@ EXTERNAL SOURCES: :path: ../ SPEC CHECKSUMS: - LGAlertView: a70295bb08ecb940da71b6009b14199a3b580453 + LGAlertView: 044299d2a66674a13c04d397555ffc5e4a666831 COCOAPODS: 0.39.0 diff --git a/LGAlertView.podspec b/LGAlertView.podspec index cb34747..c9d8c22 100644 --- a/LGAlertView.podspec +++ b/LGAlertView.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'LGAlertView' - s.version = '2.0.1' + s.version = '2.0.2' s.platform = :ios, '6.0' s.license = 'MIT' s.homepage = 'https://github.com/Friend-LGA/LGAlertView' diff --git a/LGAlertView/LGAlertView.h b/LGAlertView/LGAlertView.h index 32a753e..010b4bb 100644 --- a/LGAlertView/LGAlertView.h +++ b/LGAlertView/LGAlertView.h @@ -473,6 +473,8 @@ LGAlertViewWindowLevel; - (void)showAnimated:(BOOL)animated completionHandler:(void(^)())completionHandler; - (void)dismissAnimated:(BOOL)animated completionHandler:(void(^)())completionHandler; +- (void)transitionToAlertView:(LGAlertView *)alertView completionHandler:(void(^)())completionHandler; + - (void)setProgress:(float)progress progressLabelText:(NSString *)progressLabelText; - (void)setButtonAtIndex:(NSUInteger)index enabled:(BOOL)enabled; diff --git a/LGAlertView/LGAlertView.m b/LGAlertView/LGAlertView.m index 589d3e1..bcdd7aa 100644 --- a/LGAlertView/LGAlertView.m +++ b/LGAlertView/LGAlertView.m @@ -35,19 +35,19 @@ #import "LGAlertViewShared.h" #import "UIWindow+LGAlertView.h" -#define kLGAlertViewStatusBarHeight ([UIApplication sharedApplication].isStatusBarHidden ? 0.f : 20.f) -#define kLGAlertViewSeparatorHeight ([UIScreen mainScreen].scale == 1.f || [UIDevice currentDevice].systemVersion.floatValue < 7.0 ? 1.f : 0.5) -#define kLGAlertViewOffsetVertical (_offsetVertical >= 0 ? _offsetVertical : 8.f) -#define kLGAlertViewOffsetHorizontal 8.f -#define kLGAlertViewButtonTitleMarginH 8.f -#define kLGAlertViewWidthStyleAlert (320.f - 20*2) -#define kLGAlertViewWidthStyleActionSheet (320.f - 16*2) -#define kLGAlertViewInnerMarginH (_style == LGAlertViewStyleAlert ? 16.f : 12.f) -#define kLGAlertViewIsCancelButtonSeparate (_style == LGAlertViewStyleActionSheet && _cancelButtonOffset > 0.f && !kLGAlertViewPadAndNotForce) -#define kLGAlertViewButtonWidthMin 64.f -#define kLGAlertViewWindowPrevious(index) (index > 0 && index < kLGAlertViewWindowsArray.count ? [kLGAlertViewWindowsArray objectAtIndex:(index-1)] : nil) -#define kLGAlertViewWindowNext(index) (kLGAlertViewWindowsArray.count > index+1 ? [kLGAlertViewWindowsArray objectAtIndex:(index+1)] : nil) -#define kLGAlertViewPadAndNotForce (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad && !self.isPadShowActionSheetFromBottom) +#define kLGAlertViewStatusBarHeight ([UIApplication sharedApplication].isStatusBarHidden ? 0.f : 20.f) +#define kLGAlertViewSeparatorHeight ([UIScreen mainScreen].scale == 1.f || [UIDevice currentDevice].systemVersion.floatValue < 7.0 ? 1.f : 0.5) +#define kLGAlertViewOffsetVertical (_offsetVertical >= 0 ? _offsetVertical : 8.f) +#define kLGAlertViewOffsetHorizontal 8.f +#define kLGAlertViewButtonTitleMarginH 8.f +#define kLGAlertViewWidthStyleAlert (320.f - 20*2) +#define kLGAlertViewWidthStyleActionSheet (320.f - 16*2) +#define kLGAlertViewInnerMarginH (_style == LGAlertViewStyleAlert ? 16.f : 12.f) +#define kLGAlertViewIsCancelButtonSeparate(alertView) (alertView.style == LGAlertViewStyleActionSheet && alertView.cancelButtonOffset > 0.f && !kLGAlertViewPadAndNotForce(alertView)) +#define kLGAlertViewButtonWidthMin 64.f +#define kLGAlertViewWindowPrevious(index) (index > 0 && index < kLGAlertViewWindowsArray.count ? [kLGAlertViewWindowsArray objectAtIndex:(index-1)] : nil) +#define kLGAlertViewWindowNext(index) (kLGAlertViewWindowsArray.count > index+1 ? [kLGAlertViewWindowsArray objectAtIndex:(index+1)] : nil) +#define kLGAlertViewPadAndNotForce(alertView) (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad && !alertView.isPadShowActionSheetFromBottom) static NSMutableArray *kLGAlertViewWindowsArray; static UIColor *kLGAlertViewTintColor; @@ -1376,7 +1376,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N cell.adjustsFontSizeToFitWidth = _destructiveButtonAdjustsFontSizeToFitWidth; cell.minimumScaleFactor = _destructiveButtonMinimumScaleFactor; } - else if (_cancelButtonTitle.length && !kLGAlertViewIsCancelButtonSeparate && indexPath.row == _buttonTitles.count-1) + else if (_cancelButtonTitle.length && !kLGAlertViewIsCancelButtonSeparate(self) && indexPath.row == _buttonTitles.count-1) { cell.titleColor = _cancelButtonTitleColor; cell.titleColorHighlighted = _cancelButtonTitleColorHighlighted; @@ -1438,7 +1438,7 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa return size.height; } - else if (_cancelButtonTitle.length && !kLGAlertViewIsCancelButtonSeparate && indexPath.row == _buttonTitles.count-1 && _cancelButtonNumberOfLines != 1) + else if (_cancelButtonTitle.length && !kLGAlertViewIsCancelButtonSeparate(self) && indexPath.row == _buttonTitles.count-1 && _cancelButtonNumberOfLines != 1) { NSString *title = _buttonTitles[indexPath.row]; @@ -1509,13 +1509,18 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath #pragma mark - - (void)showAnimated:(BOOL)animated completionHandler:(void(^)())completionHandler +{ + [self showAnimated:animated hidden:NO completionHandler:completionHandler]; +} + +- (void)showAnimated:(BOOL)animated hidden:(BOOL)hidden completionHandler:(void(^)())completionHandler { if (self.isShowing) return; _window.windowLevel = UIWindowLevelStatusBar + (_windowLevel == LGAlertViewWindowLevelAboveStatusBar ? 1 : -1); _window.userInteractionEnabled = NO; - CGSize size = _viewController.view.frame.size; + CGSize size = _viewController.view.bounds.size; if ([UIDevice currentDevice].systemVersion.floatValue < 8.0) { @@ -1554,8 +1559,11 @@ - (void)showAnimated:(BOOL)animated completionHandler:(void(^)())completionHandl if (![kLGAlertViewWindowsArray containsObject:_window]) [kLGAlertViewWindowsArray addObject:_window]; - if (![windowKey isEqual:windowApp]) - windowKey.hidden = YES; + if (!hidden) + { + if (![windowKey isEqual:windowApp]) + windowKey.hidden = YES; + } [_window makeKeyAndVisible]; @@ -1570,6 +1578,21 @@ - (void)showAnimated:(BOOL)animated completionHandler:(void(^)())completionHandl // ----- + if (hidden) + { + _backgroundView.hidden = YES; + _scrollView.hidden = YES; + _styleView.hidden = YES; + + if (kLGAlertViewIsCancelButtonSeparate(self)) + { + _cancelButton.hidden = YES; + _styleCancelView.hidden = YES; + } + } + + // ----- + if (animated) { [LGAlertView animateStandardWithAnimations:^(void) @@ -1578,7 +1601,8 @@ - (void)showAnimated:(BOOL)animated completionHandler:(void(^)())completionHandl } completion:^(BOOL finished) { - [self showComplete]; + if (!hidden) + [self showComplete]; if (completionHandler) completionHandler(); }]; @@ -1587,7 +1611,8 @@ - (void)showAnimated:(BOOL)animated completionHandler:(void(^)())completionHandl { [self showAnimations]; - [self showComplete]; + if (!hidden) + [self showComplete]; if (completionHandler) completionHandler(); } @@ -1597,7 +1622,7 @@ - (void)showAnimations { _backgroundView.alpha = 1.f; - if (_style == LGAlertViewStyleAlert || kLGAlertViewPadAndNotForce) + if (_style == LGAlertViewStyleAlert || kLGAlertViewPadAndNotForce(self)) { _scrollView.transform = CGAffineTransformIdentity; _scrollView.alpha = 1.f; @@ -1612,7 +1637,7 @@ - (void)showAnimations _styleView.center = _scrollViewCenterShowed; } - if (kLGAlertViewIsCancelButtonSeparate && _cancelButton) + if (kLGAlertViewIsCancelButtonSeparate(self) && _cancelButton) { _cancelButton.center = _cancelButtonCenterShowed; @@ -1689,7 +1714,7 @@ - (void)dismissAnimations { _backgroundView.alpha = 0.f; - if (_style == LGAlertViewStyleAlert || kLGAlertViewPadAndNotForce) + if (_style == LGAlertViewStyleAlert || kLGAlertViewPadAndNotForce(self)) { _scrollView.transform = CGAffineTransformMakeScale(0.95, 0.95); _scrollView.alpha = 0.f; @@ -1704,7 +1729,7 @@ - (void)dismissAnimations _styleView.center = _scrollViewCenterHidden; } - if (kLGAlertViewIsCancelButtonSeparate && _cancelButton) + if (kLGAlertViewIsCancelButtonSeparate(self) && _cancelButton) { _cancelButton.center = _cancelButtonCenterHidden; @@ -1742,6 +1767,100 @@ - (void)dismissComplete _delegate = nil; } +- (void)transitionToAlertView:(LGAlertView *)alertView completionHandler:(void(^)())completionHandler +{ + self.window.userInteractionEnabled = NO; + + [alertView showAnimated:NO hidden:YES completionHandler:^(void) + { + NSTimeInterval duration = 0.3; + + // ----- + + [UIView animateWithDuration:duration + animations:^(void) + { + _scrollView.alpha = 0.f; + + if (kLGAlertViewIsCancelButtonSeparate(self)) + { + _cancelButton.alpha = 0.f; + + if (!kLGAlertViewIsCancelButtonSeparate(alertView)) + _styleCancelView.alpha = 0.f; + } + } + completion:^(BOOL finished) + { + alertView.backgroundView.alpha = 0.f; + alertView.backgroundView.hidden = NO; + + [UIView animateWithDuration:duration*2.f + animations:^(void) + { + _backgroundView.alpha = 0.f; + alertView.backgroundView.alpha = 1.f; + }]; + + // ----- + + CGRect styleViewFrame = alertView.styleView.frame; + + alertView.styleView.frame = _styleView.frame; + + alertView.styleView.hidden = NO; + _styleView.hidden = YES; + + [UIView animateWithDuration:duration + animations:^(void) + { + alertView.styleView.frame = styleViewFrame; + } + completion:^(BOOL finished) + { + alertView.scrollView.alpha = 0.f; + alertView.scrollView.hidden = NO; + + if (kLGAlertViewIsCancelButtonSeparate(alertView)) + { + alertView.cancelButton.alpha = 0.f; + alertView.cancelButton.hidden = NO; + + if (!_styleCancelView.alpha) + { + alertView.styleCancelView.alpha = 0.f; + alertView.styleCancelView.hidden = NO; + } + } + + [UIView animateWithDuration:duration + animations:^(void) + { + _scrollView.alpha = 0.f; + alertView.scrollView.alpha = 1.f; + + if (kLGAlertViewIsCancelButtonSeparate(alertView)) + { + alertView.cancelButton.alpha = 1.f; + + if (!alertView.styleCancelView.alpha) + alertView.styleCancelView.alpha = 1.f; + } + } + completion:^(BOOL finished) + { + [self dismissAnimated:NO completionHandler:^(void) + { + [alertView showComplete]; + + if (completionHandler) completionHandler(); + }]; + }]; + }]; + }]; + }]; +} + #pragma mark - - (void)subviewsInvalidateWithSize:(CGSize)size @@ -1945,7 +2064,7 @@ - (void)subviewsInvalidateWithSize:(CGSize)size // ----- - if (kLGAlertViewIsCancelButtonSeparate && _cancelButtonTitle) + if (kLGAlertViewIsCancelButtonSeparate(self) && _cancelButtonTitle) { _styleCancelView = [UIView new]; _styleCancelView.backgroundColor = _backgroundColor; @@ -1971,7 +2090,7 @@ - (void)subviewsInvalidateWithSize:(CGSize)size if (_destructiveButtonTitle.length) numberOfButtons++; - if (_cancelButtonTitle.length && !kLGAlertViewIsCancelButtonSeparate) + if (_cancelButtonTitle.length && !kLGAlertViewIsCancelButtonSeparate(self)) numberOfButtons++; BOOL showTable = NO; @@ -2018,7 +2137,7 @@ - (void)subviewsInvalidateWithSize:(CGSize)size showTable = YES; } - if (_cancelButtonTitle.length && !kLGAlertViewIsCancelButtonSeparate && !showTable) + if (_cancelButtonTitle.length && !kLGAlertViewIsCancelButtonSeparate(self) && !showTable) { [self cancelButtonInit]; @@ -2139,7 +2258,7 @@ - (void)subviewsInvalidateWithSize:(CGSize)size UIButton *secondButton = nil; UIButton *thirdButton = nil; - if (_cancelButton && !kLGAlertViewIsCancelButtonSeparate) + if (_cancelButton && !kLGAlertViewIsCancelButtonSeparate(self)) { [_scrollView addSubview:_cancelButton]; @@ -2257,7 +2376,7 @@ - (void)subviewsInvalidateWithSize:(CGSize)size if (showTable) { - if (!kLGAlertViewIsCancelButtonSeparate) + if (!kLGAlertViewIsCancelButtonSeparate(self)) _cancelButton = nil; _destructiveButton = nil; _firstButton = nil; @@ -2270,7 +2389,7 @@ - (void)subviewsInvalidateWithSize:(CGSize)size if (_destructiveButtonTitle.length) [_buttonTitles insertObject:_destructiveButtonTitle atIndex:0]; - if (_cancelButtonTitle.length && !kLGAlertViewIsCancelButtonSeparate) + if (_cancelButtonTitle.length && !kLGAlertViewIsCancelButtonSeparate(self)) [_buttonTitles addObject:_cancelButtonTitle]; _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; @@ -2355,7 +2474,7 @@ - (void)layoutInvalidateWithSize:(CGSize)size if (_heightMax > 0.f && _heightMax < heightMax) heightMax = _heightMax; - if (kLGAlertViewIsCancelButtonSeparate && _cancelButton) + if (kLGAlertViewIsCancelButtonSeparate(self) && _cancelButton) heightMax -= (_buttonsHeight+_cancelButtonOffset); else if (_cancelOnTouch && !_cancelButtonTitle.length && @@ -2371,7 +2490,7 @@ - (void)layoutInvalidateWithSize:(CGSize)size CGAffineTransform scrollViewTransform = CGAffineTransformIdentity; CGFloat scrollViewAlpha = 1.f; - if (_style == LGAlertViewStyleAlert || kLGAlertViewPadAndNotForce) + if (_style == LGAlertViewStyleAlert || kLGAlertViewPadAndNotForce(self)) { scrollViewFrame = CGRectMake(size.width/2-width/2, size.height/2-_keyboardHeight/2-heightMax/2, width, heightMax); @@ -2388,7 +2507,7 @@ - (void)layoutInvalidateWithSize:(CGSize)size else { CGFloat bottomShift = kLGAlertViewOffsetVertical; - if (kLGAlertViewIsCancelButtonSeparate && _cancelButton) + if (kLGAlertViewIsCancelButtonSeparate(self) && _cancelButton) bottomShift += _buttonsHeight+_cancelButtonOffset; scrollViewFrame = CGRectMake(size.width/2-width/2, size.height-bottomShift-heightMax, width, heightMax); @@ -2396,10 +2515,10 @@ - (void)layoutInvalidateWithSize:(CGSize)size // ----- - if (_style == LGAlertViewStyleActionSheet && !kLGAlertViewPadAndNotForce) + if (_style == LGAlertViewStyleActionSheet && !kLGAlertViewPadAndNotForce(self)) { CGRect cancelButtonFrame = CGRectZero; - if (kLGAlertViewIsCancelButtonSeparate && _cancelButton) + if (kLGAlertViewIsCancelButtonSeparate(self) && _cancelButton) cancelButtonFrame = CGRectMake(size.width/2-width/2, size.height-_cancelButtonOffset-_buttonsHeight, width, _buttonsHeight); _scrollViewCenterShowed = CGPointMake(scrollViewFrame.origin.x+scrollViewFrame.size.width/2, scrollViewFrame.origin.y+scrollViewFrame.size.height/2); @@ -2408,7 +2527,7 @@ - (void)layoutInvalidateWithSize:(CGSize)size // ----- CGFloat commonHeight = scrollViewFrame.size.height+kLGAlertViewOffsetVertical; - if (kLGAlertViewIsCancelButtonSeparate && _cancelButton) + if (kLGAlertViewIsCancelButtonSeparate(self) && _cancelButton) commonHeight += _buttonsHeight+_cancelButtonOffset; _scrollViewCenterHidden = CGPointMake(scrollViewFrame.origin.x+scrollViewFrame.size.width/2, scrollViewFrame.origin.y+scrollViewFrame.size.height/2+commonHeight+_layerBorderWidth+_layerShadowRadius); @@ -2418,13 +2537,13 @@ - (void)layoutInvalidateWithSize:(CGSize)size { scrollViewFrame.origin.y += commonHeight; - if (kLGAlertViewIsCancelButtonSeparate && _cancelButton) + if (kLGAlertViewIsCancelButtonSeparate(self) && _cancelButton) cancelButtonFrame.origin.y += commonHeight; } // ----- - if (kLGAlertViewIsCancelButtonSeparate && _cancelButton) + if (kLGAlertViewIsCancelButtonSeparate(self) && _cancelButton) { if ([UIScreen mainScreen].scale == 1.f) cancelButtonFrame = CGRectIntegral(cancelButtonFrame);