mirror of
https://github.com/apache/cordova-plugin-statusbar.git
synced 2025-01-19 01:12:49 +08:00
CB-13623 (iOS): Remove iOS 6-7 code
This commit is contained in:
parent
611169c89f
commit
9a976a9744
@ -97,21 +97,15 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
|||||||
|
|
||||||
-(void)statusBarDidChangeFrame:(NSNotification*)notification
|
-(void)statusBarDidChangeFrame:(NSNotification*)notification
|
||||||
{
|
{
|
||||||
//add a small delay for iOS 7 ( 0.1 seconds )
|
|
||||||
__weak CDVStatusBar* weakSelf = self;
|
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
|
|
||||||
[self resizeStatusBarBackgroundView];
|
[self resizeStatusBarBackgroundView];
|
||||||
[weakSelf resizeWebView];
|
[self resizeWebView];
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)pluginInitialize
|
- (void)pluginInitialize
|
||||||
{
|
{
|
||||||
BOOL isiOS7 = (IsAtLeastiOSVersion(@"7.0"));
|
|
||||||
|
|
||||||
// init
|
// init
|
||||||
NSNumber* uiviewControllerBasedStatusBarAppearance = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIViewControllerBasedStatusBarAppearance"];
|
NSNumber* uiviewControllerBasedStatusBarAppearance = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIViewControllerBasedStatusBarAppearance"];
|
||||||
_uiviewControllerBasedStatusBarAppearance = (uiviewControllerBasedStatusBarAppearance == nil || [uiviewControllerBasedStatusBarAppearance boolValue]) && isiOS7;
|
_uiviewControllerBasedStatusBarAppearance = (uiviewControllerBasedStatusBarAppearance == nil || [uiviewControllerBasedStatusBarAppearance boolValue]);
|
||||||
|
|
||||||
// observe the statusBarHidden property
|
// observe the statusBarHidden property
|
||||||
[[UIApplication sharedApplication] addObserver:self forKeyPath:@"statusBarHidden" options:NSKeyValueObservingOptionNew context:NULL];
|
[[UIApplication sharedApplication] addObserver:self forKeyPath:@"statusBarHidden" options:NSKeyValueObservingOptionNew context:NULL];
|
||||||
@ -206,31 +200,16 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
|||||||
statusBarFrame.origin.y = 0;
|
statusBarFrame.origin.y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
statusBarFrame = [self invertFrameIfNeeded:statusBarFrame];
|
|
||||||
|
|
||||||
_statusBarBackgroundView = [[UIView alloc] initWithFrame:statusBarFrame];
|
_statusBarBackgroundView = [[UIView alloc] initWithFrame:statusBarFrame];
|
||||||
_statusBarBackgroundView.backgroundColor = _statusBarBackgroundColor;
|
_statusBarBackgroundView.backgroundColor = _statusBarBackgroundColor;
|
||||||
_statusBarBackgroundView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin);
|
_statusBarBackgroundView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin);
|
||||||
_statusBarBackgroundView.autoresizesSubviews = YES;
|
_statusBarBackgroundView.autoresizesSubviews = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CGRect) invertFrameIfNeeded:(CGRect)rect {
|
|
||||||
// landscape is where (width > height). On iOS < 8, we need to invert since frames are
|
|
||||||
// always in Portrait context. Do not run this on ios 8 or above to avoid breaking ipad pro multitask layout
|
|
||||||
if (!IsAtLeastiOSVersion(@"8.0") && UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) {
|
|
||||||
CGFloat temp = rect.size.width;
|
|
||||||
rect.size.width = rect.size.height;
|
|
||||||
rect.size.height = temp;
|
|
||||||
rect.origin = CGPointZero;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rect;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setStatusBarOverlaysWebView:(BOOL)statusBarOverlaysWebView
|
- (void) setStatusBarOverlaysWebView:(BOOL)statusBarOverlaysWebView
|
||||||
{
|
{
|
||||||
// we only care about the latest iOS version or a change in setting
|
// we only care about the latest iOS version or a change in setting
|
||||||
if (!IsAtLeastiOSVersion(@"7.0") || statusBarOverlaysWebView == _statusBarOverlaysWebView) {
|
if (statusBarOverlaysWebView == _statusBarOverlaysWebView) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,22 +296,12 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
|||||||
|
|
||||||
- (void) styleBlackTranslucent:(CDVInvokedUrlCommand*)command
|
- (void) styleBlackTranslucent:(CDVInvokedUrlCommand*)command
|
||||||
{
|
{
|
||||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 70000
|
[self setStyleForStatusBar:UIStatusBarStyleLightContent];
|
||||||
# define TRANSLUCENT_STYLE UIStatusBarStyleBlackTranslucent
|
|
||||||
#else
|
|
||||||
# define TRANSLUCENT_STYLE UIStatusBarStyleLightContent
|
|
||||||
#endif
|
|
||||||
[self setStyleForStatusBar:TRANSLUCENT_STYLE];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) styleBlackOpaque:(CDVInvokedUrlCommand*)command
|
- (void) styleBlackOpaque:(CDVInvokedUrlCommand*)command
|
||||||
{
|
{
|
||||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 70000
|
[self setStyleForStatusBar:UIStatusBarStyleLightContent];
|
||||||
# define OPAQUE_STYLE UIStatusBarStyleBlackOpaque
|
|
||||||
#else
|
|
||||||
# define OPAQUE_STYLE UIStatusBarStyleLightContent
|
|
||||||
#endif
|
|
||||||
[self setStyleForStatusBar:OPAQUE_STYLE];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) backgroundColorByName:(CDVInvokedUrlCommand*)command
|
- (void) backgroundColorByName:(CDVInvokedUrlCommand*)command
|
||||||
@ -396,9 +365,7 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
|||||||
|
|
||||||
[self hideStatusBar];
|
[self hideStatusBar];
|
||||||
|
|
||||||
if (IsAtLeastiOSVersion(@"7.0")) {
|
|
||||||
[_statusBarBackgroundView removeFromSuperview];
|
[_statusBarBackgroundView removeFromSuperview];
|
||||||
}
|
|
||||||
|
|
||||||
[self resizeWebView];
|
[self resizeWebView];
|
||||||
|
|
||||||
@ -426,13 +393,9 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
|||||||
|
|
||||||
if (app.isStatusBarHidden)
|
if (app.isStatusBarHidden)
|
||||||
{
|
{
|
||||||
BOOL isIOS7 = (IsAtLeastiOSVersion(@"7.0"));
|
|
||||||
|
|
||||||
[self showStatusBar];
|
[self showStatusBar];
|
||||||
[self resizeWebView];
|
[self resizeWebView];
|
||||||
|
|
||||||
if (isIOS7) {
|
|
||||||
|
|
||||||
if (!self.statusBarOverlaysWebView) {
|
if (!self.statusBarOverlaysWebView) {
|
||||||
|
|
||||||
// there is a possibility that when the statusbar was hidden, it was in a different orientation
|
// there is a possibility that when the statusbar was hidden, it was in a different orientation
|
||||||
@ -443,15 +406,12 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
_statusBarBackgroundView.hidden = NO;
|
_statusBarBackgroundView.hidden = NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)resizeStatusBarBackgroundView {
|
-(void)resizeStatusBarBackgroundView {
|
||||||
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
|
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
|
||||||
statusBarFrame = [self invertFrameIfNeeded:statusBarFrame];
|
|
||||||
CGRect sbBgFrame = _statusBarBackgroundView.frame;
|
CGRect sbBgFrame = _statusBarBackgroundView.frame;
|
||||||
sbBgFrame.size = statusBarFrame.size;
|
sbBgFrame.size = statusBarFrame.size;
|
||||||
_statusBarBackgroundView.frame = sbBgFrame;
|
_statusBarBackgroundView.frame = sbBgFrame;
|
||||||
@ -459,22 +419,18 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
|||||||
|
|
||||||
-(void)resizeWebView
|
-(void)resizeWebView
|
||||||
{
|
{
|
||||||
BOOL isIOS7 = (IsAtLeastiOSVersion(@"7.0"));
|
|
||||||
BOOL isIOS11 = (IsAtLeastiOSVersion(@"11.0"));
|
BOOL isIOS11 = (IsAtLeastiOSVersion(@"11.0"));
|
||||||
|
|
||||||
if (isIOS7) {
|
|
||||||
CGRect bounds = [self.viewController.view.window bounds];
|
CGRect bounds = [self.viewController.view.window bounds];
|
||||||
if (CGRectEqualToRect(bounds, CGRectZero)) {
|
if (CGRectEqualToRect(bounds, CGRectZero)) {
|
||||||
bounds = [[UIScreen mainScreen] bounds];
|
bounds = [[UIScreen mainScreen] bounds];
|
||||||
}
|
}
|
||||||
bounds = [self invertFrameIfNeeded:bounds];
|
|
||||||
|
|
||||||
self.viewController.view.frame = bounds;
|
self.viewController.view.frame = bounds;
|
||||||
|
|
||||||
self.webView.frame = bounds;
|
self.webView.frame = bounds;
|
||||||
|
|
||||||
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
|
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
|
||||||
statusBarFrame = [self invertFrameIfNeeded:statusBarFrame];
|
|
||||||
CGRect frame = self.webView.frame;
|
CGRect frame = self.webView.frame;
|
||||||
CGFloat height = statusBarFrame.size.height;
|
CGFloat height = statusBarFrame.size.height;
|
||||||
|
|
||||||
@ -498,10 +454,7 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
|||||||
}
|
}
|
||||||
frame.size.height -= frame.origin.y;
|
frame.size.height -= frame.origin.y;
|
||||||
self.webView.frame = frame;
|
self.webView.frame = frame;
|
||||||
} else {
|
|
||||||
CGRect bounds = [[UIScreen mainScreen] applicationFrame];
|
|
||||||
self.viewController.view.frame = bounds;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
|
Loading…
Reference in New Issue
Block a user