Skip to content

Commit

Permalink
add support for storyboard images
Browse files Browse the repository at this point in the history
inspired by devgeeks#62
  • Loading branch information
hbolte committed Jun 19, 2020
1 parent 5ce1914 commit 14c76b7
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/ios/PrivacyScreenPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ - (void)onAppWillResignActive:(UIApplication *)application
imageView = [[UIImageView alloc]initWithFrame:[self.viewController.view bounds]];
imageView.contentMode = UIViewContentModeScaleAspectFill;
[imageView setImage:splash];


if ([self isUsingCDVLaunchScreen]) {
// launch screen expects the image to be scaled using AspectFill.
imageView.contentMode = UIViewContentModeScaleAspectFill;
}

#ifdef __CORDOVA_4_0_0
[[UIApplication sharedApplication].keyWindow addSubview:imageView];
#else
Expand Down Expand Up @@ -75,13 +80,27 @@ - (CDV_iOSDevice) getCurrentDevice
return device;
}

- (BOOL) isUsingCDVLaunchScreen {
NSString* launchStoryboardName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchStoryboardName"];
if (launchStoryboardName) {
return ([launchStoryboardName isEqualToString:@"CDVLaunchScreen"]);
} else {
return NO;
}
}

- (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(id<CDVScreenOrientationDelegate>)orientationDelegate device:(CDV_iOSDevice)device
{
// Use UILaunchImageFile if specified in plist. Otherwise, use Default.
NSString* imageName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchImageFile"];

NSUInteger supportedOrientations = [orientationDelegate supportedInterfaceOrientations];


// Detect if we are using Launch Storyboard and return the associated image instead
if ([self isUsingCDVLaunchScreen]) {
imageName = @"LaunchStoryboard";
return imageName;
}
// Checks to see if the developer has locked the orientation to use only one of Portrait or Landscape
BOOL supportsLandscape = (supportedOrientations & UIInterfaceOrientationMaskLandscape);
BOOL supportsPortrait = (supportedOrientations & UIInterfaceOrientationMaskPortrait || supportedOrientations & UIInterfaceOrientationMaskPortraitUpsideDown);
Expand Down

0 comments on commit 14c76b7

Please sign in to comment.