Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes and improvements #94

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions KVNProgress/Categories/UIColor+KVNContrast.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions KVNProgress/Classes/KVNProgress.m
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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];
Expand Down
8 changes: 8 additions & 0 deletions KVNProgress/Classes/KVNProgressConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>KVNProgressConfiguration</code> with default configuration. */
Expand Down
4 changes: 4 additions & 0 deletions KVNProgress/Classes/KVNProgressConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ - (id)init

_tapBlock = nil;
_allowUserInteraction = NO;

_supportedOrientations = UIInterfaceOrientationMaskAll;
}

return self;
Expand Down Expand Up @@ -78,6 +80,8 @@ - (id)copyWithZone:(NSZone *)zone

copy.tapBlock = self.tapBlock;
copy.allowUserInteraction = self.allowUserInteraction;

copy.supportedOrientations = self.supportedOrientations;

return copy;
}
Expand Down
2 changes: 2 additions & 0 deletions KVNProgress/Classes/KVNRotationViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
*/
@interface KVNRotationViewController : UIViewController

@property (nonatomic, assign) UIInterfaceOrientationMask supportedOrientations;

@end
13 changes: 12 additions & 1 deletion KVNProgress/Classes/KVNRotationViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down