Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 612EE101DE for ; Thu, 13 Mar 2014 19:59:00 +0000 (UTC) Received: (qmail 3806 invoked by uid 500); 13 Mar 2014 19:58:42 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 3355 invoked by uid 500); 13 Mar 2014 19:58:33 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 3251 invoked by uid 99); 13 Mar 2014 19:58:30 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Mar 2014 19:58:30 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 3F71E944F5B; Thu, 13 Mar 2014 19:58:30 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: shazron@apache.org To: commits@cordova.apache.org Date: Thu, 13 Mar 2014 19:58:33 -0000 Message-Id: <703a0ff138f947b785657602e3837917@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [04/35] git commit: Added ability to set statusbar background color by hex string. Added ability to set statusbar background color by hex string. Project: http://git-wip-us.apache.org/repos/asf/cordova-statusbar/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-statusbar/commit/058c6b71 Tree: http://git-wip-us.apache.org/repos/asf/cordova-statusbar/tree/058c6b71 Diff: http://git-wip-us.apache.org/repos/asf/cordova-statusbar/diff/058c6b71 Branch: refs/heads/master Commit: 058c6b71cc45b9fa29579fece2a30fc384ea1b35 Parents: da275b5 Author: Shazron Abdullah Authored: Sun Oct 6 01:18:06 2013 -0700 Committer: Shazron Abdullah Committed: Sun Oct 6 01:18:06 2013 -0700 ---------------------------------------------------------------------- src/ios/CDVStatusBar.h | 1 + src/ios/CDVStatusBar.m | 20 ++++++++++++++++++++ www/statusbar.js | 4 ++++ 3 files changed, 25 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-statusbar/blob/058c6b71/src/ios/CDVStatusBar.h ---------------------------------------------------------------------- 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 http://git-wip-us.apache.org/repos/asf/cordova-statusbar/blob/058c6b71/src/ios/CDVStatusBar.m ---------------------------------------------------------------------- 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 http://git-wip-us.apache.org/repos/asf/cordova-statusbar/blob/058c6b71/www/statusbar.js ---------------------------------------------------------------------- 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;