Skip to content

Commit 14c76b7

Browse files
committed
add support for storyboard images
inspired by devgeeks#62
1 parent 5ce1914 commit 14c76b7

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/ios/PrivacyScreenPlugin.m

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ - (void)onAppWillResignActive:(UIApplication *)application
4040
imageView = [[UIImageView alloc]initWithFrame:[self.viewController.view bounds]];
4141
imageView.contentMode = UIViewContentModeScaleAspectFill;
4242
[imageView setImage:splash];
43-
43+
44+
if ([self isUsingCDVLaunchScreen]) {
45+
// launch screen expects the image to be scaled using AspectFill.
46+
imageView.contentMode = UIViewContentModeScaleAspectFill;
47+
}
48+
4449
#ifdef __CORDOVA_4_0_0
4550
[[UIApplication sharedApplication].keyWindow addSubview:imageView];
4651
#else
@@ -75,13 +80,27 @@ - (CDV_iOSDevice) getCurrentDevice
7580
return device;
7681
}
7782

83+
- (BOOL) isUsingCDVLaunchScreen {
84+
NSString* launchStoryboardName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchStoryboardName"];
85+
if (launchStoryboardName) {
86+
return ([launchStoryboardName isEqualToString:@"CDVLaunchScreen"]);
87+
} else {
88+
return NO;
89+
}
90+
}
91+
7892
- (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(id<CDVScreenOrientationDelegate>)orientationDelegate device:(CDV_iOSDevice)device
7993
{
8094
// Use UILaunchImageFile if specified in plist. Otherwise, use Default.
8195
NSString* imageName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchImageFile"];
8296

8397
NSUInteger supportedOrientations = [orientationDelegate supportedInterfaceOrientations];
84-
98+
99+
// Detect if we are using Launch Storyboard and return the associated image instead
100+
if ([self isUsingCDVLaunchScreen]) {
101+
imageName = @"LaunchStoryboard";
102+
return imageName;
103+
}
85104
// Checks to see if the developer has locked the orientation to use only one of Portrait or Landscape
86105
BOOL supportsLandscape = (supportedOrientations & UIInterfaceOrientationMaskLandscape);
87106
BOOL supportsPortrait = (supportedOrientations & UIInterfaceOrientationMaskPortrait || supportedOrientations & UIInterfaceOrientationMaskPortraitUpsideDown);

0 commit comments

Comments
 (0)