mirror of
https://github.com/apache/cordova-plugin-statusbar.git
synced 2026-04-27 00:00:06 +08:00
Added ability to set statusbar background color by hex string.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user