Skip to content

Instantly share code, notes, and snippets.

@janziemba
Forked from benvium/react-native-ios-splash.m
Created January 11, 2018 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janziemba/f3a452d30b3ed0e1be718dc719007788 to your computer and use it in GitHub Desktop.
Save janziemba/f3a452d30b3ed0e1be718dc719007788 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