Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Launch screen in React Native

I'm working with a React Native app and I'm trying to set a customize launch screen but I'm not able to.

React Native creates a LaunchScreen.xib by default, so I've created a LaunchImage inside Images.xcassets:

LaunchImage in Images.xcassets

I've also read that I've to modify the "Launch Screen File" under "App Icons and Launch Images" in my options:

Launch Images options

Once I've done that, my launch screen became totally black and when the app is loaded, there are both top and bottom black frames:

enter image description here

So I don't know what I have to do to set my launch screen in my React Native project.

I'll be grateful if someone can help me out with those troubles.

Thanks in advance.

like image 245
JV Lobo Avatar asked Dec 01 '15 18:12

JV Lobo


People also ask

How add splash screen iOS in react native?

Manually set a blank, single-color splash screen background on the native side. On iOS, set the background color of the React Native root view to that same color. As soon as React Native loads, add a View with the same color in React Native and fade in the app logo on it. Once the app loads, fade out the splash screen.

How do you make a splash screen in react?

Show activity on this post. import React from 'react'; import './Splash. css' import img2 from '../../Assets/Header. png' import img8 from '../../Assets/hand.

How do you use Bootsplash in react native?

Open the React Native project in Xcode and have your React Native project in your finder. In the iOS folder, drag and drop Bootsplash. storyboard into Xcode. You will get a prompt; click on “finish.”


2 Answers

I was be able to solve the issue, with the help of this thread: Launch Image not showing up in iOS application (using Images.xcassets)

So I'm gonna explain it deeply in case it can help someone else.

First, you need to create certain images. What I used for that was this template and this webpage with an automatic generator: TiCons

enter image description here

When I downloaded my images, I took the ones inside assets/iphone folder, I only took those ones:

Also you need this Contents.json file in the same folder, I got it from a friend:

{   "images": [     {       "extent": "full-screen",       "idiom": "iphone",       "filename": "[email protected]",       "minimum-system-version": "7.0",       "orientation": "portrait",       "scale": "2x",       "subtype": "retina4"     },     {       "extent": "full-screen",       "idiom": "iphone",       "filename": "[email protected]",       "minimum-system-version": "8.0",       "orientation": "portrait",       "scale": "2x",       "subtype": "667h"     },     {       "extent": "full-screen",       "idiom": "iphone",       "filename": "[email protected]",       "minimum-system-version": "8.0",       "orientation": "landscape",       "scale": "3x",       "subtype": "736h"     },     {       "extent": "full-screen",       "idiom": "iphone",       "filename": "[email protected]",       "minimum-system-version": "8.0",       "orientation": "portrait",       "scale": "3x",       "subtype": "736h"     },     {       "extent": "full-screen",       "idiom": "iphone",       "filename": "[email protected]",       "minimum-system-version": "7.0",       "orientation": "portrait",       "scale": "2x"     }   ],   "info": {     "version": 1,     "author": "xcode"   } } 

So, at this point I created a folder called LaunchImage.launchimage inside Images.xcassets folder in my React Native project and save the images and the Contents.json file inside it:

enter image description here

Second, you have to open your project in Xcode and in "General" settings, below "App icons and Launch Images" we have to leave the option "Launch Screen File" empty (also we can delete the LaunchScreen.xib file inside our project), and click in "Use Asset Catalog" after that. A modal will open, we choose to Migrate the catalog Images

enter image description here

Now, in the "Launch Images Source" selector, we can choose the folder we created before, LaunchImage (the one with our images):

enter image description here

We pick this instead of Brand Assets and we can delete Brand Assets folder.

At this point, we'll be able to run our React Native application with our custom launch images:

enter image description here

I know it seems a little bit complex for an supposedly easy task, but after reading a lot about it this was the only way I could get my splash images working, so I wanted to share with the community.

like image 195
JV Lobo Avatar answered Sep 20 '22 14:09

JV Lobo


Make sure to delete the app from the simulator. Then do a clean on your project.

like image 37
Dan G Nelson Avatar answered Sep 18 '22 14:09

Dan G Nelson