Merge pull request #146 from jcesarmobile/CB-13737
CB-13737 (iOS): fix Splash screen images for iPhone X
diff --git a/src/ios/CDVSplashScreen.h b/src/ios/CDVSplashScreen.h
index ec5d602..dcc0d77 100644
--- a/src/ios/CDVSplashScreen.h
+++ b/src/ios/CDVSplashScreen.h
@@ -28,6 +28,7 @@
BOOL iPhone6;
BOOL iPhone6Plus;
BOOL retina;
+ BOOL iPhoneX;
} CDV_iOSDevice;
diff --git a/src/ios/CDVSplashScreen.m b/src/ios/CDVSplashScreen.m
index ab97055..9b04582 100644
--- a/src/ios/CDVSplashScreen.m
+++ b/src/ios/CDVSplashScreen.m
@@ -74,7 +74,7 @@
// Determine whether rotation should be enabled for this device
// Per iOS HIG, landscape is only supported on iPad and iPhone 6+
CDV_iOSDevice device = [self getCurrentDevice];
- BOOL autorotateValue = (device.iPad || device.iPhone6Plus) ?
+ BOOL autorotateValue = (device.iPad || device.iPhone6Plus || device.iPhoneX) ?
[(CDVViewController *)self.viewController shouldAutorotateDefaultValue] :
NO;
@@ -174,6 +174,7 @@
// this is appropriate for detecting the runtime screen environment
device.iPhone6 = (device.iPhone && limit == 667.0);
device.iPhone6Plus = (device.iPhone && limit == 736.0);
+ device.iPhoneX = (device.iPhone && limit == 812.0);
return device;
}
@@ -222,8 +223,12 @@
imageName = [imageName stringByAppendingString:@"-700"];
} else if(device.iPhone6) {
imageName = [imageName stringByAppendingString:@"-800"];
- } else if(device.iPhone6Plus) {
- imageName = [imageName stringByAppendingString:@"-800"];
+ } else if(device.iPhone6Plus || device.iPhoneX ) {
+ if(device.iPhone6Plus) {
+ imageName = [imageName stringByAppendingString:@"-800"];
+ } else {
+ imageName = [imageName stringByAppendingString:@"-1100"];
+ }
if (currentOrientation == UIInterfaceOrientationPortrait || currentOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
imageName = [imageName stringByAppendingString:@"-Portrait"];
@@ -239,7 +244,7 @@
{ // does not support landscape
imageName = [imageName stringByAppendingString:@"-667h"];
}
- else if (device.iPhone6Plus)
+ else if (device.iPhone6Plus || device.iPhoneX)
{ // supports landscape
if (isOrientationLocked)
{
@@ -257,8 +262,11 @@
break;
}
}
- imageName = [imageName stringByAppendingString:@"-736h"];
-
+ if (device.iPhoneX) {
+ imageName = [imageName stringByAppendingString:@"-2436h"];
+ } else {
+ imageName = [imageName stringByAppendingString:@"-736h"];
+ }
}
else if (device.iPad)
{ // supports landscape
@@ -370,7 +378,7 @@
* correctly.
*/
CDV_iOSDevice device = [self getCurrentDevice];
- if (UIInterfaceOrientationIsLandscape(orientation) && !device.iPhone6Plus && !device.iPad)
+ if (UIInterfaceOrientationIsLandscape(orientation) && !device.iPhone6Plus && !device.iPad && !device.iPhoneX)
{
imgTransform = CGAffineTransformMakeRotation(M_PI / 2);
imgBounds.size = CGSizeMake(imgBounds.size.height, imgBounds.size.width);