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 112EC10C63 for ; Thu, 13 Mar 2014 23:14:41 +0000 (UTC) Received: (qmail 40124 invoked by uid 500); 13 Mar 2014 23:14:17 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 40048 invoked by uid 500); 13 Mar 2014 23:14:15 -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 40014 invoked by uid 99); 13 Mar 2014 23:14:14 -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 23:14:14 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 8C4D39805FD; Thu, 13 Mar 2014 23:14:14 +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 23:14:16 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [03/35] git commit: Added statusbar background, including API to change its background color Added statusbar background, including API to change its background color Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/commit/da275b57 Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/tree/da275b57 Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/diff/da275b57 Branch: refs/heads/dev Commit: da275b579fbb3642635d0777082f7b96ae003e20 Parents: 2e15c9c Author: Shazron Abdullah Authored: Sun Oct 6 00:47:33 2013 -0700 Committer: Shazron Abdullah Committed: Sun Oct 6 00:47:33 2013 -0700 ---------------------------------------------------------------------- src/ios/CDVStatusBar.h | 3 +++ src/ios/CDVStatusBar.m | 22 ++++++++++++++++++++++ www/statusbar.js | 4 ++++ 3 files changed, 29 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/blob/da275b57/src/ios/CDVStatusBar.h ---------------------------------------------------------------------- diff --git a/src/ios/CDVStatusBar.h b/src/ios/CDVStatusBar.h index 298b3f5..124128e 100644 --- a/src/ios/CDVStatusBar.h +++ b/src/ios/CDVStatusBar.h @@ -23,6 +23,8 @@ @interface CDVStatusBar : CDVPlugin { @protected BOOL _statusBarOverlaysWebView; + @protected + UIView* _statusBarBackgroundView; } @property (atomic, assign) BOOL statusBarOverlaysWebView; @@ -34,5 +36,6 @@ - (void) styleBlackTranslucent:(CDVInvokedUrlCommand*)command; - (void) styleBlackOpaque:(CDVInvokedUrlCommand*)command; +- (void) statusBarBackgroundColorByName:(CDVInvokedUrlCommand*)command; @end http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/blob/da275b57/src/ios/CDVStatusBar.m ---------------------------------------------------------------------- diff --git a/src/ios/CDVStatusBar.m b/src/ios/CDVStatusBar.m index 9fe4632..e2a660c 100644 --- a/src/ios/CDVStatusBar.m +++ b/src/ios/CDVStatusBar.m @@ -36,6 +36,11 @@ { _statusBarOverlaysWebView = YES; // default + CGRect frame = [[UIApplication sharedApplication] statusBarFrame]; + + _statusBarBackgroundView = [[UIView alloc] initWithFrame:frame]; + _statusBarBackgroundView.backgroundColor = [UIColor blackColor]; + NSString* setting = @"StatusBarOverlaysWebView"; if ([self settingForKey:setting]) { self.statusBarOverlaysWebView = [(NSNumber*)[self settingForKey:setting] boolValue]; @@ -57,6 +62,8 @@ bounds.size.height += statusBarFrame.size.height; self.webView.frame = bounds; + + [_statusBarBackgroundView removeFromSuperview]; } else { CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame; @@ -65,6 +72,8 @@ bounds.size.height -= statusBarFrame.size.height; self.webView.frame = bounds; + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque]; + [self.webView.superview addSubview:_statusBarBackgroundView]; } _statusBarOverlaysWebView = statusBarOverlaysWebView; @@ -105,4 +114,17 @@ [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque]; } +- (void) statusBarBackgroundColorByName:(CDVInvokedUrlCommand*)command +{ + id value = [command.arguments objectAtIndex:0]; + if (!([value isKindOfClass:[NSString class]])) { + value = @"black"; + } + + SEL selector = NSSelectorFromString([value stringByAppendingString:@"Color"]); + if ([UIColor respondsToSelector:selector]) { + _statusBarBackgroundView.backgroundColor = [UIColor performSelector:selector]; + } +} + @end http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/blob/da275b57/www/statusbar.js ---------------------------------------------------------------------- diff --git a/www/statusbar.js b/www/statusbar.js index 8c461bd..6a2ca9e 100644 --- a/www/statusbar.js +++ b/www/statusbar.js @@ -46,6 +46,10 @@ StatusBar.styleBlackOpaque = function() { exec(null, null, "StatusBar", "styleBlackOpaque", []); }; +StatusBar.statusBarBackgroundColorByName = function(colorname) { + exec(null, null, "StatusBar", "statusBarBackgroundColorByName", [colorname]); +} + // TODO: StatusBar.isVisible = true;