mirror of
https://github.com/apache/cordova-plugin-statusbar.git
synced 2025-02-26 12:52:50 +08:00
CB-5389 - iOS - Status Bar plugin issues with orientation
This commit is contained in:
parent
062dfceb29
commit
fee10a1334
@ -27,6 +27,8 @@
|
|||||||
UIView* _statusBarBackgroundView;
|
UIView* _statusBarBackgroundView;
|
||||||
@protected
|
@protected
|
||||||
BOOL _uiviewControllerBasedStatusBarAppearance;
|
BOOL _uiviewControllerBasedStatusBarAppearance;
|
||||||
|
@protected
|
||||||
|
UIColor* _statusBarBackgroundColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (atomic, assign) BOOL statusBarOverlaysWebView;
|
@property (atomic, assign) BOOL statusBarOverlaysWebView;
|
||||||
|
@ -103,6 +103,7 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
|||||||
[self initializeStatusBarBackgroundView];
|
[self initializeStatusBarBackgroundView];
|
||||||
|
|
||||||
[self styleLightContent:nil]; // match default backgroundColor of #000000
|
[self styleLightContent:nil]; // match default backgroundColor of #000000
|
||||||
|
self.viewController.view.autoresizesSubviews = YES;
|
||||||
|
|
||||||
NSString* setting;
|
NSString* setting;
|
||||||
|
|
||||||
@ -132,8 +133,9 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
|||||||
}
|
}
|
||||||
|
|
||||||
_statusBarBackgroundView = [[UIView alloc] initWithFrame:statusBarFrame];
|
_statusBarBackgroundView = [[UIView alloc] initWithFrame:statusBarFrame];
|
||||||
_statusBarBackgroundView.backgroundColor = [UIColor blackColor];
|
_statusBarBackgroundView.backgroundColor = _statusBarBackgroundColor;
|
||||||
_statusBarBackgroundView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin);
|
_statusBarBackgroundView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin);
|
||||||
|
_statusBarBackgroundView.autoresizesSubviews = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setStatusBarOverlaysWebView:(BOOL)statusBarOverlaysWebView
|
- (void) setStatusBarOverlaysWebView:(BOOL)statusBarOverlaysWebView
|
||||||
@ -267,7 +269,8 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
|||||||
[scanner setScanLocation:1];
|
[scanner setScanLocation:1];
|
||||||
[scanner scanHexInt:&rgbValue];
|
[scanner scanHexInt:&rgbValue];
|
||||||
|
|
||||||
_statusBarBackgroundView.backgroundColor = [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0 green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0 alpha:1.0];
|
_statusBarBackgroundColor = [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0 green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0 alpha:1.0];
|
||||||
|
_statusBarBackgroundView.backgroundColor = _statusBarBackgroundColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) backgroundColorByHexString:(CDVInvokedUrlCommand*)command
|
- (void) backgroundColorByHexString:(CDVInvokedUrlCommand*)command
|
||||||
@ -304,16 +307,25 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
|||||||
if (!app.isStatusBarHidden)
|
if (!app.isStatusBarHidden)
|
||||||
{
|
{
|
||||||
self.viewController.wantsFullScreenLayout = YES;
|
self.viewController.wantsFullScreenLayout = YES;
|
||||||
|
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
|
||||||
|
|
||||||
[self hideStatusBar];
|
[self hideStatusBar];
|
||||||
|
|
||||||
if (IsAtLeastiOSVersion(@"7.0")) {
|
if (IsAtLeastiOSVersion(@"7.0")) {
|
||||||
[_statusBarBackgroundView removeFromSuperview];
|
[_statusBarBackgroundView removeFromSuperview];
|
||||||
}
|
}
|
||||||
|
|
||||||
CGRect bounds = [[UIScreen mainScreen] bounds];
|
CGRect frame = self.webView.frame;
|
||||||
|
frame.origin.y = 0;
|
||||||
|
|
||||||
self.viewController.view.frame = bounds;
|
if (UIDeviceOrientationIsLandscape(self.viewController.interfaceOrientation)) {
|
||||||
self.webView.frame = bounds;
|
frame.size.height += statusBarFrame.size.width;
|
||||||
|
} else {
|
||||||
|
frame.size.height += statusBarFrame.size.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.webView.frame = frame;
|
||||||
|
_statusBarBackgroundView.hidden = YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,25 +354,41 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
|||||||
[self showStatusBar];
|
[self showStatusBar];
|
||||||
|
|
||||||
if (isIOS7) {
|
if (isIOS7) {
|
||||||
CGRect bounds = [[UIScreen mainScreen] bounds];
|
CGRect frame = self.webView.frame;
|
||||||
self.viewController.view.frame = bounds;
|
self.viewController.view.frame = [[UIScreen mainScreen] bounds];
|
||||||
|
|
||||||
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
|
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
|
||||||
|
|
||||||
if (!self.statusBarOverlaysWebView) {
|
if (!self.statusBarOverlaysWebView) {
|
||||||
bounds.origin.y = statusBarFrame.size.height;
|
|
||||||
bounds.size.height -= statusBarFrame.size.height;
|
|
||||||
|
|
||||||
|
// there is a possibility that when the statusbar was hidden, it was in a different orientation
|
||||||
|
// from the current one. Therefore we need to expand the statusBarBackgroundView as well to the
|
||||||
|
// statusBar's current size
|
||||||
|
CGRect sbBgFrame = _statusBarBackgroundView.frame;
|
||||||
|
|
||||||
|
if (UIDeviceOrientationIsLandscape(self.viewController.interfaceOrientation)) {
|
||||||
|
frame.origin.y = statusBarFrame.size.width;
|
||||||
|
frame.size.height -= statusBarFrame.size.width;
|
||||||
|
sbBgFrame.size = CGSizeMake(statusBarFrame.size.height, statusBarFrame.size.width);
|
||||||
|
} else {
|
||||||
|
frame.origin.y = statusBarFrame.size.height;
|
||||||
|
frame.size.height -= statusBarFrame.size.height;
|
||||||
|
sbBgFrame.size = statusBarFrame.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
_statusBarBackgroundView.frame = sbBgFrame;
|
||||||
[self.webView.superview addSubview:_statusBarBackgroundView];
|
[self.webView.superview addSubview:_statusBarBackgroundView];
|
||||||
}
|
}
|
||||||
|
|
||||||
self.webView.frame = bounds;
|
self.webView.frame = frame;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
CGRect bounds = [[UIScreen mainScreen] applicationFrame];
|
CGRect bounds = [[UIScreen mainScreen] applicationFrame];
|
||||||
self.viewController.view.frame = bounds;
|
self.viewController.view.frame = bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_statusBarBackgroundView.hidden = NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user