@@ -767,7 +767,18 @@ - (void)onWebViewPageDidLoad:(NSNotification*)notification
767767 self.webView .hidden = NO ;
768768
769769 if ([self .settings cordovaBoolSettingForKey: @" AutoHideSplashScreen" defaultValue: YES ]) {
770- [self showLaunchScreen: NO ];
770+ CGFloat splashScreenDelaySetting = [self .settings cordovaFloatSettingForKey: @" SplashScreenDelay" defaultValue: 0 ];
771+
772+ if (splashScreenDelaySetting == 0 ) {
773+ [self showLaunchScreen: NO ];
774+ } else {
775+ // Divide by 1000 because config returns milliseconds and NSTimer takes seconds
776+ CGFloat splashScreenDelay = splashScreenDelaySetting / 1000 ;
777+
778+ [NSTimer scheduledTimerWithTimeInterval: splashScreenDelay repeats: NO block: ^(NSTimer * _Nonnull timer) {
779+ [self showLaunchScreen: NO ];
780+ }];
781+ }
771782 }
772783}
773784
@@ -776,22 +787,16 @@ - (void)onWebViewPageDidLoad:(NSNotification*)notification
776787 */
777788- (void )showLaunchScreen : (BOOL )visible
778789{
779- CGFloat splashScreenDelay = [self .settings cordovaFloatSettingForKey: @" SplashScreenDelay" defaultValue: 0 ];
780-
781- // AnimateWithDuration takes seconds but cordova documentation specifies milliseconds
782790 CGFloat fadeSplashScreenDuration = [self .settings cordovaFloatSettingForKey: @" FadeSplashScreenDuration" defaultValue: 250 ];
783791
784792 // Setting minimum value for fade to 0.25 seconds
785793 fadeSplashScreenDuration = fadeSplashScreenDuration < 250 ? 250 : fadeSplashScreenDuration;
786794
787- // Divide by 1000 because config returns milliseconds and NSTimer takes seconds
788- CGFloat delayToFade = (MAX (splashScreenDelay, fadeSplashScreenDuration) - fadeSplashScreenDuration)/1000 ;
795+ // AnimateWithDuration takes seconds but cordova documentation specifies milliseconds
789796 CGFloat fadeDuration = fadeSplashScreenDuration/1000 ;
790797
791- [NSTimer scheduledTimerWithTimeInterval: delayToFade repeats: NO block: ^(NSTimer * _Nonnull timer) {
792- [UIView animateWithDuration: fadeDuration animations: ^{
793- [self .launchView setAlpha: (visible ? 1 : 0 )];
794- }];
798+ [UIView animateWithDuration: fadeDuration animations: ^{
799+ [self .launchView setAlpha: (visible ? 1 : 0 )];
795800 }];
796801}
797802
0 commit comments