You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2013/10/06 10:18:13 UTC
git commit: Added ability to set statusbar background color by hex
string.
Updated Branches:
refs/heads/plugins c019e95cf -> 9b6c3c8ab
Added ability to set statusbar background color by hex string.
Project: http://git-wip-us.apache.org/repos/asf/cordova-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-labs/commit/9b6c3c8a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-labs/tree/9b6c3c8a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-labs/diff/9b6c3c8a
Branch: refs/heads/plugins
Commit: 9b6c3c8abaca735805baea057c2b3105e45e0a4f
Parents: c019e95
Author: Shazron Abdullah <sh...@apache.org>
Authored: Sun Oct 6 01:18:06 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Sun Oct 6 01:18:06 2013 -0700
----------------------------------------------------------------------
statusbar/src/ios/CDVStatusBar.h | 1 +
statusbar/src/ios/CDVStatusBar.m | 20 ++++++++++++++++++++
statusbar/www/statusbar.js | 4 ++++
3 files changed, 25 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/9b6c3c8a/statusbar/src/ios/CDVStatusBar.h
----------------------------------------------------------------------
diff --git a/statusbar/src/ios/CDVStatusBar.h b/statusbar/src/ios/CDVStatusBar.h
index 124128e..3c9d573 100644
--- a/statusbar/src/ios/CDVStatusBar.h
+++ b/statusbar/src/ios/CDVStatusBar.h
@@ -37,5 +37,6 @@
- (void) styleBlackOpaque:(CDVInvokedUrlCommand*)command;
- (void) statusBarBackgroundColorByName:(CDVInvokedUrlCommand*)command;
+- (void) statusBarBackgroundColorByHexString:(CDVInvokedUrlCommand*)command;
@end
http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/9b6c3c8a/statusbar/src/ios/CDVStatusBar.m
----------------------------------------------------------------------
diff --git a/statusbar/src/ios/CDVStatusBar.m b/statusbar/src/ios/CDVStatusBar.m
index e2a660c..7a301b8 100644
--- a/statusbar/src/ios/CDVStatusBar.m
+++ b/statusbar/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
http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/9b6c3c8a/statusbar/www/statusbar.js
----------------------------------------------------------------------
diff --git a/statusbar/www/statusbar.js b/statusbar/www/statusbar.js
index 6a2ca9e..b570881 100644
--- a/statusbar/www/statusbar.js
+++ b/statusbar/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;