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; diff --git a/KVNProgress/Classes/KVNProgress.m b/KVNProgress/Classes/KVNProgress.m index b41d420..9873d3e 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. @@ -896,6 +899,11 @@ - (void)addToView:(UIView *)superview return; } + // 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]; [self removeFromSuperview]; 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