Added statusbar background, including API to change its background color

This commit is contained in:
Shazron Abdullah
2013-10-06 00:47:33 -07:00
parent 2e15c9c025
commit da275b579f
3 changed files with 29 additions and 0 deletions
+22
View File
@@ -36,6 +36,11 @@
{
_statusBarOverlaysWebView = YES; // default
CGRect frame = [[UIApplication sharedApplication] statusBarFrame];
_statusBarBackgroundView = [[UIView alloc] initWithFrame:frame];
_statusBarBackgroundView.backgroundColor = [UIColor blackColor];
NSString* setting = @"StatusBarOverlaysWebView";
if ([self settingForKey:setting]) {
self.statusBarOverlaysWebView = [(NSNumber*)[self settingForKey:setting] boolValue];
@@ -57,6 +62,8 @@
bounds.size.height += statusBarFrame.size.height;
self.webView.frame = bounds;
[_statusBarBackgroundView removeFromSuperview];
} else {
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
@@ -65,6 +72,8 @@
bounds.size.height -= statusBarFrame.size.height;
self.webView.frame = bounds;
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];
[self.webView.superview addSubview:_statusBarBackgroundView];
}
_statusBarOverlaysWebView = statusBarOverlaysWebView;
@@ -105,4 +114,17 @@
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];
}
- (void) statusBarBackgroundColorByName:(CDVInvokedUrlCommand*)command
{
id value = [command.arguments objectAtIndex:0];
if (!([value isKindOfClass:[NSString class]])) {
value = @"black";
}
SEL selector = NSSelectorFromString([value stringByAppendingString:@"Color"]);
if ([UIColor respondsToSelector:selector]) {
_statusBarBackgroundView.backgroundColor = [UIColor performSelector:selector];
}
}
@end