Merge pull request #146 from jcesarmobile/CB-13737

CB-13737 (iOS): fix Splash screen images for iPhone X
This commit is contained in:
jcesarmobile 2018-01-09 20:00:00 +01:00 committed by GitHub
commit be8be330ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 7 deletions

View File

@ -28,6 +28,7 @@ typedef struct {
BOOL iPhone6;
BOOL iPhone6Plus;
BOOL retina;
BOOL iPhoneX;
} CDV_iOSDevice;

View File

@ -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);