Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native - Odd spaces on iPhone X

Tags:

react-native

When i try to build my app to simulator running iPhone X there's an odd spaces on top and bottom of the screen as shown in the image. It's supposed to be full screen. Any idea how i can fix this? Thanks in advance.

i am running rn v0.47 and xcode 9.

enter image description here

like image 580
jayfred Avatar asked Sep 20 '17 08:09

jayfred


People also ask

Is iPhone x React Native?

In version 0.50. 1, the React Native team introduced a new API for easily dealing with the new iPhone X layout. This API is the SafeAreaView.

Is SafeAreaView only for iOS?

The purpose of SafeAreaView is to render content within the safe area boundaries of a device. It is currently only applicable to iOS devices with iOS version 11 or later.

Should I use SafeAreaView in React Native?

You have to only use when any screen has headerMode:none or it out side of the navigation. If you are using full screen modal then you should use <SafeAreaView> . I don't thing having navigation handles it. For android it might but for iOS with swipe gesture to go to home on bottom, one must use safeareview.

Where do I put SafeAreaView?

import { SafeAreaView } from 'react-native'; You just use it in place of the top-level View component. It makes sure content within the safe area boundaries is properly rendered around the nested content and applies padding automatically.


2 Answers

Probably you are setting the launch screen as images, try by setting the LaunchScreen as a storyboard and be sure to have the Use Safe Area Layout Guides active on it.

enter image description here

enter image description here

If you don't have a LaunchScreen.storyboard you can just create a new one an set it, or create a new empty project and just grab the existing LaunchScreen.storyboard and copy/paste it to your current project.

like image 195
Camo Avatar answered Oct 29 '22 06:10

Camo


Camo's answer is right. The issue is related on splash screen. But i just wanted to share how i fixed my issue since I am not using storyboard for my launchScreen. So first i created a new launchscreen image with dimensions 1125x2436(portrait) and 2436x1125(landscape) and added it to my launchimage directory. And then updated the Contents.json file adding this 2 configurations:

{
 "orientation" : "portrait",
 "idiom" : "iphone",
 "extent" : "full-screen",
 "minimum-system-version" : "11.0",
 "filename" : "1125x2436.png",
 "subtype" : "2436h",
 "scale" : "3x"
},
{
 "orientation" : "landscape",
 "idiom" : "iphone",
 "extent" : "full-screen",
 "minimum-system-version" : "11.0",
 "filename" : "2436x1125.png",
 "subtype" : "2436h",
 "scale" : "3x"
}
like image 24
jayfred Avatar answered Oct 29 '22 06:10

jayfred