Skip to content

Commit be8be33

Browse files
authored
Merge pull request #146 from jcesarmobile/CB-13737
CB-13737 (iOS): fix Splash screen images for iPhone X
2 parents b5e0c78 + 4ffaaa2 commit be8be33

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/ios/CDVSplashScreen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ typedef struct {
2828
BOOL iPhone6;
2929
BOOL iPhone6Plus;
3030
BOOL retina;
31+
BOOL iPhoneX;
3132

3233
} CDV_iOSDevice;
3334

src/ios/CDVSplashScreen.m

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ - (void)createViews
7474
// Determine whether rotation should be enabled for this device
7575
// Per iOS HIG, landscape is only supported on iPad and iPhone 6+
7676
CDV_iOSDevice device = [self getCurrentDevice];
77-
BOOL autorotateValue = (device.iPad || device.iPhone6Plus) ?
77+
BOOL autorotateValue = (device.iPad || device.iPhone6Plus || device.iPhoneX) ?
7878
[(CDVViewController *)self.viewController shouldAutorotateDefaultValue] :
7979
NO;
8080

@@ -174,6 +174,7 @@ - (CDV_iOSDevice) getCurrentDevice
174174
// this is appropriate for detecting the runtime screen environment
175175
device.iPhone6 = (device.iPhone && limit == 667.0);
176176
device.iPhone6Plus = (device.iPhone && limit == 736.0);
177+
device.iPhoneX = (device.iPhone && limit == 812.0);
177178

178179
return device;
179180
}
@@ -222,8 +223,12 @@ - (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(i
222223
imageName = [imageName stringByAppendingString:@"-700"];
223224
} else if(device.iPhone6) {
224225
imageName = [imageName stringByAppendingString:@"-800"];
225-
} else if(device.iPhone6Plus) {
226-
imageName = [imageName stringByAppendingString:@"-800"];
226+
} else if(device.iPhone6Plus || device.iPhoneX ) {
227+
if(device.iPhone6Plus) {
228+
imageName = [imageName stringByAppendingString:@"-800"];
229+
} else {
230+
imageName = [imageName stringByAppendingString:@"-1100"];
231+
}
227232
if (currentOrientation == UIInterfaceOrientationPortrait || currentOrientation == UIInterfaceOrientationPortraitUpsideDown)
228233
{
229234
imageName = [imageName stringByAppendingString:@"-Portrait"];
@@ -239,7 +244,7 @@ - (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(i
239244
{ // does not support landscape
240245
imageName = [imageName stringByAppendingString:@"-667h"];
241246
}
242-
else if (device.iPhone6Plus)
247+
else if (device.iPhone6Plus || device.iPhoneX)
243248
{ // supports landscape
244249
if (isOrientationLocked)
245250
{
@@ -257,8 +262,11 @@ - (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(i
257262
break;
258263
}
259264
}
260-
imageName = [imageName stringByAppendingString:@"-736h"];
261-
265+
if (device.iPhoneX) {
266+
imageName = [imageName stringByAppendingString:@"-2436h"];
267+
} else {
268+
imageName = [imageName stringByAppendingString:@"-736h"];
269+
}
262270
}
263271
else if (device.iPad)
264272
{ // supports landscape
@@ -370,7 +378,7 @@ - (void)updateBounds
370378
* correctly.
371379
*/
372380
CDV_iOSDevice device = [self getCurrentDevice];
373-
if (UIInterfaceOrientationIsLandscape(orientation) && !device.iPhone6Plus && !device.iPad)
381+
if (UIInterfaceOrientationIsLandscape(orientation) && !device.iPhone6Plus && !device.iPad && !device.iPhoneX)
374382
{
375383
imgTransform = CGAffineTransformMakeRotation(M_PI / 2);
376384
imgBounds.size = CGSizeMake(imgBounds.size.height, imgBounds.size.width);

0 commit comments

Comments
 (0)