diff --git a/SCLAlertView/SCLAlertView.m b/SCLAlertView/SCLAlertView.m index 0bac909..860428a 100755 --- a/SCLAlertView/SCLAlertView.m +++ b/SCLAlertView/SCLAlertView.m @@ -118,12 +118,16 @@ - (instancetype)initWithNewWindow - (instancetype)initWithNewWindowWidth:(CGFloat)windowWidth { + #ifndef SCL_IS_APP_EXTENSION self = [self initWithWindowWidth:windowWidth]; if(self) { [self setupNewWindow]; } return self; + #else + return [self initWithWindowWidth:windowWidth]; + #endif } - (void)dealloc @@ -309,15 +313,15 @@ - (void)viewWillLayoutSubviews sz = _rootViewController.view.frame.size; } - if (SYSTEM_VERSION_LESS_THAN(@"8.0")) - { - // iOS versions before 7.0 did not switch the width and height on device roration - if (UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) - { - CGSize ssz = sz; - sz = CGSizeMake(ssz.height, ssz.width); - } - } +// if (SYSTEM_VERSION_LESS_THAN(@"8.0")) +// { +// // iOS versions before 7.0 did not switch the width and height on device roration +// if (UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) +// { +// CGSize ssz = sz; +// sz = CGSizeMake(ssz.height, ssz.width); +// } +// } // Set new background frame CGRect newBackgroundFrame = self.backgroundView.frame; @@ -804,12 +808,14 @@ - (SCLAlertViewResponder *)showTitle:(UIViewController *)vc image:(UIImage *)ima { if(_usingNewWindow) { + #ifndef SCL_IS_APP_EXTENSION // Save previous window self.previousWindow = [UIApplication sharedApplication].keyWindow; self.backgroundView.frame = _SCLAlertWindow.bounds; // Add window subview [_SCLAlertWindow addSubview:_backgroundView]; + #endif } else { @@ -1179,12 +1185,17 @@ - (SCLForceHideBlock)forceHideBlock:(SCLForceHideBlock)forceHideBlock - (CGRect)mainScreenFrame { - return [self isAppExtension] ? _extensionBounds : [UIApplication sharedApplication].keyWindow.bounds; -} - -- (BOOL)isAppExtension -{ - return [[NSBundle mainBundle].executablePath rangeOfString:@".appex/"].location != NSNotFound; +// return [self isAppExtension] ? _extensionBounds : [UIApplication sharedApplication].keyWindow.bounds; +//} +// +//- (BOOL)isAppExtension +//{ +// return [[NSBundle mainBundle].executablePath rangeOfString:@".appex/"].location != NSNotFound; + #ifndef SCL_IS_APP_EXTENSION + return [UIApplication sharedApplication].keyWindow.bounds; + #else + return _extensionBounds; + #endif } #pragma mark - Background Effects @@ -1199,7 +1210,11 @@ - (void)makeShadowBackground - (void)makeBlurBackground { + #ifndef SCL_IS_APP_EXTENSION UIView *appView = (_usingNewWindow) ? [UIApplication sharedApplication].keyWindow.subviews.lastObject : _rootViewController.view; + #else + UIView *appView = _rootViewController.view; + #endif UIImage *image = [UIImage convertViewToImage:appView]; UIImage *blurSnapshotImage = [image applyBlurWithRadius:5.0f tintColor:[UIColor colorWithWhite:0.2f diff --git a/SCLAlertView/UIImage+ImageEffects.h b/SCLAlertView/UIImage+ImageEffects.h index e5fd509..af98554 100755 --- a/SCLAlertView/UIImage+ImageEffects.h +++ b/SCLAlertView/UIImage+ImageEffects.h @@ -109,7 +109,7 @@ - (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage; + (UIImage *)imageWithColor:(UIColor *)color; -+ (UIImage *)convertViewToImage; +//+ (UIImage *)convertViewToImage; + (UIImage *)convertViewToImage:(UIView *)view; @end diff --git a/SCLAlertView/UIImage+ImageEffects.m b/SCLAlertView/UIImage+ImageEffects.m index 280560e..2b53f96 100755 --- a/SCLAlertView/UIImage+ImageEffects.m +++ b/SCLAlertView/UIImage+ImageEffects.m @@ -294,18 +294,18 @@ + (UIImage *)imageWithColor:(UIColor *)color return image; } -+ (UIImage *)convertViewToImage -{ - UIWindow *keyWindow = [[UIApplication sharedApplication]keyWindow]; - CGRect rect = [keyWindow bounds]; - UIGraphicsBeginImageContextWithOptions(rect.size, YES, 0.0f); - CGContextRef context = UIGraphicsGetCurrentContext(); - [keyWindow.layer renderInContext:context]; - UIImage *capturedScreen = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - - return capturedScreen; -} +//+ (UIImage *)convertViewToImage +//{ +// UIWindow *keyWindow = [[UIApplication sharedApplication]keyWindow]; +// CGRect rect = [keyWindow bounds]; +// UIGraphicsBeginImageContextWithOptions(rect.size, YES, 0.0f); +// CGContextRef context = UIGraphicsGetCurrentContext(); +// [keyWindow.layer renderInContext:context]; +// UIImage *capturedScreen = UIGraphicsGetImageFromCurrentImageContext(); +// UIGraphicsEndImageContext(); +// +// return capturedScreen; +//} + (UIImage *)convertViewToImage:(UIView *)view {