mirror of
https://github.com/apache/cordova-plugin-statusbar.git
synced 2025-01-19 01:12:49 +08:00
Added ability to set statusbar background color by hex string.
This commit is contained in:
parent
da275b579f
commit
058c6b71cc
@ -37,5 +37,6 @@
|
||||
- (void) styleBlackOpaque:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
- (void) statusBarBackgroundColorByName:(CDVInvokedUrlCommand*)command;
|
||||
- (void) statusBarBackgroundColorByHexString:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
@end
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user