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 0681EE3DA for ; Fri, 1 Mar 2013 19:10:43 +0000 (UTC) Received: (qmail 76138 invoked by uid 500); 1 Mar 2013 19:10:42 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 76091 invoked by uid 500); 1 Mar 2013 19:10:42 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 76083 invoked by uid 99); 1 Mar 2013 19:10:42 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Mar 2013 19:10:42 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 6058C3B9C2; Fri, 1 Mar 2013 19:10:42 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: agrieve@apache.org To: commits@cordova.apache.org X-Mailer: ASF-Git Admin Mailer Subject: ios commit: [CB-2220] Fix splash screen positioning when image is the size of device Message-Id: <20130301191042.6058C3B9C2@tyr.zones.apache.org> Date: Fri, 1 Mar 2013 19:10:42 +0000 (UTC) Updated Branches: refs/heads/master 9473991d8 -> 65924ef25 [CB-2220] Fix splash screen positioning when image is the size of device Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/65924ef2 Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/65924ef2 Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/65924ef2 Branch: refs/heads/master Commit: 65924ef25f69bbe297e89d0ba6f40aca51bb26c5 Parents: 9473991 Author: Andrew Grieve Authored: Fri Mar 1 14:06:33 2013 -0500 Committer: Andrew Grieve Committed: Fri Mar 1 14:06:33 2013 -0500 ---------------------------------------------------------------------- CordovaLib/Classes/CDVSplashScreen.m | 24 +++++++++++++++--------- 1 files changed, 15 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/65924ef2/CordovaLib/Classes/CDVSplashScreen.m ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVSplashScreen.m b/CordovaLib/Classes/CDVSplashScreen.m index cd4ed9d..2c55461 100644 --- a/CordovaLib/Classes/CDVSplashScreen.m +++ b/CordovaLib/Classes/CDVSplashScreen.m @@ -140,19 +140,25 @@ - (void)updateBounds { UIImage* img = _imageView.image; - CGRect viewBounds = self.viewController.view.bounds; CGRect imgBounds = CGRectMake(0, 0, img.size.width, img.size.height); - CGFloat imgAspect = imgBounds.size.width / imgBounds.size.height; - CGFloat viewAspect = viewBounds.size.width / viewBounds.size.height; + CGSize screenSize = [self.viewController.view convertRect:[UIScreen mainScreen].bounds fromView:nil].size; - // This matches the behaviour of the native splash screen. - if (viewAspect > imgAspect) { - CGFloat ratio = viewBounds.size.width / imgBounds.size.width; - imgBounds.size.height *= ratio; - imgBounds.size.width *= ratio; + // There's a special case when the image is the size of the screen. + if (CGSizeEqualToSize(screenSize, imgBounds.size)) { + CGRect statusFrame = [self.viewController.view convertRect:[UIApplication sharedApplication].statusBarFrame fromView:nil]; + imgBounds.origin.y -= statusFrame.size.height; } else { - CGFloat ratio = viewBounds.size.height / imgBounds.size.height; + CGRect viewBounds = self.viewController.view.bounds; + CGFloat imgAspect = imgBounds.size.width / imgBounds.size.height; + CGFloat viewAspect = viewBounds.size.width / viewBounds.size.height; + // This matches the behaviour of the native splash screen. + CGFloat ratio; + if (viewAspect > imgAspect) { + ratio = viewBounds.size.width / imgBounds.size.width; + } else { + ratio = viewBounds.size.height / imgBounds.size.height; + } imgBounds.size.height *= ratio; imgBounds.size.width *= ratio; }