Install the library using either Yarn:
yarn add rnative-splash
(or)
For npm use
npm install rnative-splash --save
If using cocoapods in the ios/
directory run
cd ios
pod install
NOTE: If you ever need to uninstall rnative-splash, run react-native unlink rnative-splash
to unlink it.
This line is [RCTSplashScreen open: rootView withImageNamed: @" splash "];
Add before the rootView.backgroundColor
line.
In AppDelegate.m
...
#import "RCTSplashScreen.h" //import interface
...
[RCTSplashScreen open:rootView withImageNamed:@"splash"]; // <-- activate splash, imagename from LaunchScreen.xib
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
...
return YES
The following changes are required for xcode.
Delete your project's LaunchScreen.xib
Let's move the SplashScreenResource folder under the ios/
folder.
cp -R ./node_modules/rnative-splash/ios/SplashScreenResource ios/
Drag SplashScreenResource folder to your project if you want change image, replace splash.png or add a image with your custom name.
--
it's that simple 🎉🎉🎉🎉🎉🎉🎉
You can continue to Usage it here.