mirror of
https://github.com/apache/cordova-plugin-statusbar.git
synced 2026-04-27 00:00:06 +08:00
Implement StatusBar.isVisible
This commit is contained in:
@@ -40,8 +40,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString*)keyPath ofObject:(id)object change:(NSDictionary*)change context:(void*)context
|
||||
{
|
||||
if ([keyPath isEqual:@"statusBarHidden"]) {
|
||||
NSNumber* newValue = [change objectForKey:NSKeyValueChangeNewKey];
|
||||
BOOL boolValue = [newValue boolValue];
|
||||
|
||||
[self.commandDelegate evalJs:[NSString stringWithFormat:@"StatusBar.isVisible = %@;", boolValue? @"true" : @"false" ]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)pluginInitialize
|
||||
{
|
||||
// observe the statusBarHidden property
|
||||
[[UIApplication sharedApplication] addObserver:self forKeyPath:@"statusBarHidden" options:NSKeyValueObservingOptionNew context:NULL];
|
||||
|
||||
_statusBarOverlaysWebView = YES; // default
|
||||
|
||||
CGRect frame = [[UIApplication sharedApplication] statusBarFrame];
|
||||
@@ -65,6 +78,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _ready:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
// set the initial value
|
||||
[self.commandDelegate evalJs:[NSString stringWithFormat:@"StatusBar.isVisible = %@;", [UIApplication sharedApplication].statusBarHidden? @"false" : @"true" ]];
|
||||
}
|
||||
|
||||
- (void) setStatusBarOverlaysWebView:(BOOL)statusBarOverlaysWebView
|
||||
{
|
||||
// we only care about the latest iOS version or a change in setting
|
||||
@@ -184,5 +203,10 @@
|
||||
[self _backgroundColorByHexString:value];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[[UIApplication sharedApplication] removeObserver:self forKeyPath:@"statusBarHidden"];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user