diff --git a/src/ios/CDVStatusBar.h b/src/ios/CDVStatusBar.h index 124128e..3c9d573 100644 --- a/src/ios/CDVStatusBar.h +++ b/src/ios/CDVStatusBar.h @@ -37,5 +37,6 @@ - (void) styleBlackOpaque:(CDVInvokedUrlCommand*)command; - (void) statusBarBackgroundColorByName:(CDVInvokedUrlCommand*)command; +- (void) statusBarBackgroundColorByHexString:(CDVInvokedUrlCommand*)command; @end diff --git a/src/ios/CDVStatusBar.m b/src/ios/CDVStatusBar.m index e2a660c..7a301b8 100644 --- a/src/ios/CDVStatusBar.m +++ b/src/ios/CDVStatusBar.m @@ -127,4 +127,24 @@ } } +- (void) statusBarBackgroundColorByHexString:(CDVInvokedUrlCommand*)command +{ + NSString* value = [command.arguments objectAtIndex:0]; + if (!([value isKindOfClass:[NSString class]])) { + value = @"#000000"; + } + + if (![value hasPrefix:@"#"] || [value length] < 7) { + return; + } + + unsigned int rgbValue = 0; + NSScanner* scanner = [NSScanner scannerWithString:value]; + [scanner setScanLocation:1]; + [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]; +} + + @end diff --git a/www/statusbar.js b/www/statusbar.js index 6a2ca9e..b570881 100644 --- a/www/statusbar.js +++ b/www/statusbar.js @@ -50,6 +50,10 @@ StatusBar.statusBarBackgroundColorByName = function(colorname) { exec(null, null, "StatusBar", "statusBarBackgroundColorByName", [colorname]); } +StatusBar.statusBarBackgroundColorByHexString = function(hexString) { + exec(null, null, "StatusBar", "statusBarBackgroundColorByHexString", [hexString]); +} + // TODO: StatusBar.isVisible = true;