From fe73d82e441ae326b5d6d0472a6465f2d31e9251 Mon Sep 17 00:00:00 2001 From: Konstantin Bakalov Date: Wed, 24 Aug 2016 17:06:04 +0300 Subject: [PATCH 1/4] Added supportedOrientations property to KVNProgressConfiguration --- KVNProgress/Classes/KVNProgress.m | 3 +++ KVNProgress/Classes/KVNProgressConfiguration.h | 8 ++++++++ KVNProgress/Classes/KVNProgressConfiguration.m | 4 ++++ KVNProgress/Classes/KVNRotationViewController.h | 2 ++ KVNProgress/Classes/KVNRotationViewController.m | 13 ++++++++++++- 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/KVNProgress/Classes/KVNProgress.m b/KVNProgress/Classes/KVNProgress.m index b41d420..4bbd946 100644 --- a/KVNProgress/Classes/KVNProgress.m +++ b/KVNProgress/Classes/KVNProgress.m @@ -879,6 +879,9 @@ - (void)addToWindow self.progressWindow.rootViewController = [[KVNRotationViewController alloc] init]; } + KVNRotationViewController *rotationVC = (KVNRotationViewController *)self.progressWindow.rootViewController; + rotationVC.supportedOrientations = self.configuration.supportedOrientations; + self.progressWindow.frame = self.originalKeyWindow.frame; // Since iOS 9.0 set the windowsLevel to UIWindowLevelStatusBar is not working anymore. diff --git a/KVNProgress/Classes/KVNProgressConfiguration.h b/KVNProgress/Classes/KVNProgressConfiguration.h index c2c7a13..aaa05dc 100644 --- a/KVNProgress/Classes/KVNProgressConfiguration.h +++ b/KVNProgress/Classes/KVNProgressConfiguration.h @@ -96,6 +96,14 @@ typedef NS_ENUM(NSUInteger, KVNProgressBackgroundType) { */ @property (nonatomic, getter = doesAllowUserInteraction) BOOL allowUserInteraction; +#pragma mark - Interface Orientations + +/** + * Specify supported orientations to be used by KVNRotationViewController. + * Default value is UIInterfaceOrientationMaskAll. + */ +@property (nonatomic, assign) UIInterfaceOrientationMask supportedOrientations; + #pragma mark - Helper /** Create an instance of KVNProgressConfiguration with default configuration. */ diff --git a/KVNProgress/Classes/KVNProgressConfiguration.m b/KVNProgress/Classes/KVNProgressConfiguration.m index 698e4bc..d72e907 100644 --- a/KVNProgress/Classes/KVNProgressConfiguration.m +++ b/KVNProgress/Classes/KVNProgressConfiguration.m @@ -41,6 +41,8 @@ - (id)init _tapBlock = nil; _allowUserInteraction = NO; + + _supportedOrientations = UIInterfaceOrientationMaskAll; } return self; @@ -78,6 +80,8 @@ - (id)copyWithZone:(NSZone *)zone copy.tapBlock = self.tapBlock; copy.allowUserInteraction = self.allowUserInteraction; + + copy.supportedOrientations = self.supportedOrientations; return copy; } diff --git a/KVNProgress/Classes/KVNRotationViewController.h b/KVNProgress/Classes/KVNRotationViewController.h index d7ce6a1..8d03501 100644 --- a/KVNProgress/Classes/KVNRotationViewController.h +++ b/KVNProgress/Classes/KVNRotationViewController.h @@ -14,4 +14,6 @@ */ @interface KVNRotationViewController : UIViewController +@property (nonatomic, assign) UIInterfaceOrientationMask supportedOrientations; + @end diff --git a/KVNProgress/Classes/KVNRotationViewController.m b/KVNProgress/Classes/KVNRotationViewController.m index 916488c..03cfd70 100644 --- a/KVNProgress/Classes/KVNRotationViewController.m +++ b/KVNProgress/Classes/KVNRotationViewController.m @@ -14,9 +14,20 @@ */ @implementation KVNRotationViewController +- (instancetype)init +{ + self = [super init]; + + if (self) { + self.supportedOrientations = UIInterfaceOrientationMaskAll; + } + + return self; +} + - (UIInterfaceOrientationMask)supportedInterfaceOrientations { - return UIInterfaceOrientationMaskAll; + return self.supportedOrientations; } - (BOOL)shouldAutorotate From 9a05b9728c7f2be318a838bc5b98a3691f7eb27d Mon Sep 17 00:00:00 2001 From: Dimitar Lazarov Date: Sun, 23 Oct 2016 13:25:28 +0100 Subject: [PATCH 2/4] Fixed out of the bounds memory read when color is not in the RGB color space --- KVNProgress/Categories/UIColor+KVNContrast.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/KVNProgress/Categories/UIColor+KVNContrast.m b/KVNProgress/Categories/UIColor+KVNContrast.m index 411bdb0..4a70fff 100644 --- a/KVNProgress/Categories/UIColor+KVNContrast.m +++ b/KVNProgress/Categories/UIColor+KVNContrast.m @@ -12,8 +12,11 @@ @implementation UIColor (KVNContrast) - (UIStatusBarStyle)statusBarStyleConstrastStyle { - const CGFloat *componentColors = CGColorGetComponents(self.CGColor); - CGFloat darknessScore = (((componentColors[0] * 255) * 299) + ((componentColors[1] * 255) * 587) + ((componentColors[2] * 255) * 114)) / 1000; + CGFloat red = 0, green = 0, blue = 0; + + [self getRed:&red green:&green blue:&blue alpha:nil]; + + CGFloat darknessScore = (((red * 255) * 299) + ((green * 255) * 587) + ((blue * 255) * 114)) / 1000; if (darknessScore >= 125) { return UIStatusBarStyleDefault; From 16fea0343c37720a2dd7aa1402b06b17068752a5 Mon Sep 17 00:00:00 2001 From: Galin Kardzhilov Date: Mon, 24 Oct 2016 16:51:29 +0300 Subject: [PATCH 3/4] Fixes an issue with blurred background missing when KVN is opened with onView param --- KVNProgress/Classes/KVNProgress.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/KVNProgress/Classes/KVNProgress.m b/KVNProgress/Classes/KVNProgress.m index 4bbd946..c3a13c4 100644 --- a/KVNProgress/Classes/KVNProgress.m +++ b/KVNProgress/Classes/KVNProgress.m @@ -899,6 +899,8 @@ - (void)addToView:(UIView *)superview return; } + self.originalKeyWindow = [UIApplication sharedApplication].keyWindow; + if (self.superview) { [self.superview removeConstraints:self.constraintsToSuperview]; [self removeFromSuperview]; From 764de4e8f1f1581be0ed81082dbdd20d0f1711f9 Mon Sep 17 00:00:00 2001 From: Dimitar Lazarov Date: Mon, 24 Oct 2016 17:40:34 +0100 Subject: [PATCH 4/4] Fixes an issue with blurred background missing when KVN is opened with onView param --- KVNProgress/Classes/KVNProgress.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/KVNProgress/Classes/KVNProgress.m b/KVNProgress/Classes/KVNProgress.m index c3a13c4..9873d3e 100644 --- a/KVNProgress/Classes/KVNProgress.m +++ b/KVNProgress/Classes/KVNProgress.m @@ -899,7 +899,10 @@ - (void)addToView:(UIView *)superview return; } - self.originalKeyWindow = [UIApplication sharedApplication].keyWindow; + // Set current window as original so we can use it in blurredScreenShot + if (self.originalKeyWindow == nil) { + self.originalKeyWindow = [UIApplication sharedApplication].keyWindow; + } if (self.superview) { [self.superview removeConstraints:self.constraintsToSuperview];