Skip to content

Instantly share code, notes, and snippets.

@benvium
Created February 23, 2016 10:00
Show Gist options
  • Save benvium/47283efabf795e93316a to your computer and use it in GitHub Desktop.
Save benvium/47283efabf795e93316a to your computer and use it in GitHub Desktop.
React Native iOS Smooth Splash Screen (when using LaunchScreen.xib)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
...
...
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"MyAwesomeApp"
initialProperties:@{}
launchOptions:launchOptions];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
// re-load the LaunchScreen to prevent white screen showing before your app renders
UIView* launchScreen = [[[NSBundle mainBundle] loadNibNamed:@"LaunchScreen" owner:self options:nil] objectAtIndex:0];
launchScreen.frame = [UIScreen mainScreen].bounds;
rootView.loadingView = launchScreen;
rootView.loadingViewFadeDelay = 0.20;
rootView.loadingViewFadeDuration = 0.30;
return YES;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment