You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/03/01 20:10:42 UTC

ios commit: [CB-2220] Fix splash screen positioning when image is the size of device

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 <ag...@chromium.org>
Authored: Fri Mar 1 14:06:33 2013 -0500
Committer: Andrew Grieve <ag...@chromium.org>
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;
     }