incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject ios commit: adjust splash screen position based on orientation and status bar size
Date Tue, 24 Apr 2012 20:14:46 GMT
Updated Branches:
  refs/heads/master f22c4f218 -> 73620e43a


adjust splash screen position based on orientation and status bar size


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/73620e43
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/73620e43
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/73620e43

Branch: refs/heads/master
Commit: 73620e43ad1ddec1a5f23472b6f18a2348ca8681
Parents: f22c4f2
Author: Tom Clarkson <tom@orangeguava.com>
Authored: Fri Apr 20 00:15:35 2012 +1000
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Tue Apr 24 12:53:49 2012 -0700

----------------------------------------------------------------------
 CordovaLib/Classes/CDVViewController.m |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/73620e43/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.m b/CordovaLib/Classes/CDVViewController.m
index d663f9f..57ac48a 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -603,10 +603,14 @@
     CGAffineTransform startupImageTransform = CGAffineTransformIdentity;
     UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
     CGRect screenBounds = [[UIScreen mainScreen] bounds];
+    CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
     UIInterfaceOrientation statusBarOrientation = [UIApplication sharedApplication].statusBarOrientation;
     BOOL isIPad = [[self class] isIPad];
     UIImage* launchImage = nil;
     
+    // default to center of screen as in the original implementation. This will produce the
20px jump
+    CGPoint center = CGPointMake((screenBounds.size.width / 2), (screenBounds.size.height
/ 2));
+    
     if (isIPad)
     {
         if (!UIDeviceOrientationIsValidInterfaceOrientation(deviceOrientation)) {
@@ -619,18 +623,21 @@
             {
                 orientedLaunchImageFile = [NSString stringWithFormat:@"%@-Landscape", launchImageFile];
                 startupImageTransform = CGAffineTransformMakeRotation(degreesToRadian(90));
+                center.x -= MIN(statusBarFrame.size.width, statusBarFrame.size.height)/2;
             }
                 break;
             case UIDeviceOrientationLandscapeRight: // this is where the home button is on
the left (yeah, I know, confusing)
             {
                 orientedLaunchImageFile = [NSString stringWithFormat:@"%@-Landscape", launchImageFile];
                 startupImageTransform = CGAffineTransformMakeRotation(degreesToRadian(-90));
-            } 
+                center.x += MIN(statusBarFrame.size.width, statusBarFrame.size.height)/2;
+           } 
                 break;
             case UIDeviceOrientationPortraitUpsideDown:
             {
                 orientedLaunchImageFile = [NSString stringWithFormat:@"%@-Portrait", launchImageFile];
                 startupImageTransform = CGAffineTransformMakeRotation(degreesToRadian(180));
+                center.y -= MIN(statusBarFrame.size.width, statusBarFrame.size.height)/2;
             } 
                 break;
             case UIDeviceOrientationPortrait:
@@ -638,6 +645,7 @@
             {
                 orientedLaunchImageFile = [NSString stringWithFormat:@"%@-Portrait", launchImageFile];
                 startupImageTransform = CGAffineTransformIdentity;
+                center.y += MIN(statusBarFrame.size.width, statusBarFrame.size.height)/2;
             }
                 break;
         }
@@ -656,7 +664,7 @@
     
     self.imageView = [[[UIImageView alloc] initWithImage:launchImage] autorelease];    
     self.imageView.tag = 1;
-    self.imageView.center = CGPointMake((screenBounds.size.width / 2), (screenBounds.size.height
/ 2));
+    self.imageView.center = center;
     
     self.imageView.autoresizingMask = (UIViewAutoresizingFlexibleWidth & UIViewAutoresizingFlexibleHeight
& UIViewAutoresizingFlexibleLeftMargin & UIViewAutoresizingFlexibleRightMargin); 
  
     [self.imageView setTransform:startupImageTransform];


Mime
View raw message