[英]Top & Bottom black borders are surrounding the react native app in iPhone 11 simulator
I am new to react-native.我是 react-native 的新手。 I tried to build a sound player for animals using a react-native sound player.
我尝试使用 react-native 声音播放器为动物构建声音播放器。 I could successfully launch the Android App without any design issues.
我可以成功启动 Android 应用程序而没有任何设计问题。 But I couldn't complete the iOS app due to a design issue.
但由于设计问题,我无法完成 iOS 应用程序。
This is the splash screen of the app.这是应用程序的启动画面。 Big black top and bottom borders are covering the application.
大的黑色顶部和底部边框覆盖了应用程序。 I want to remove these black borders.
我想删除这些黑色边框。
Below is the App.js file of the application,下面是应用程序的 App.js 文件,
import React, {Component} from 'react';
import {createStackNavigator} from '@react-navigation/stack';
import {NavigationContainer} from '@react-navigation/native';
import SplashScreen from './src/screens/SplashScreen';
import HomeScreen from './src/screens/HomeScreen';
import AnimalCategory from './src/screens/AnimalCategory';
import Animal from './src/screens/Animals';
import {SafeAreaProvider} from 'react-native-safe-area-context';
const Stack = createStackNavigator();
export default class App extends Component {
render() {
return (
<SafeAreaProvider>
<NavigationContainer independent={true}>
<Stack.Navigator
initialRouteName="SplashScreen"
component={SplashScreen}
screenOptions={{headerShown: false}}>
<Stack.Screen
name="SplashScreen"
component={SplashScreen}
options={{headerShown: false}}
/>
<Stack.Screen
name="HomeScreen"
component={HomeScreen}
options={{headerShown: false}}
/>
<Stack.Screen
name="AnimalCategory"
component={AnimalCategory}
options={{headerShown: false}}
/>
<Stack.Screen
name="Animal"
component={Animal}
options={{headerShown: false}}
/>
</Stack.Navigator>
</NavigationContainer>
</SafeAreaProvider>
);
}
}
And this is the SplashScreen.js,这是 SplashScreen.js,
import React, {Component} from 'react';
import {View, Text, StyleSheet, Image, PermissionsAndroid} from 'react-native';
import ComponentStyles from '../../constant/Component.styles';
import {BG, CL} from '../../assets/images/index';
import {SafeAreaView} from 'react-native-safe-area-context';
export default class SplashScreen extends Component {
constructor(props) {
super(props);
}
async componentDidMount() {
setTimeout(() => {
this.props.navigation.replace('AnimalCategory');
}, 2000);
}
render() {
return (
<SafeAreaView
style={{
flex: 1,
justifyContent: 'space-between',
alignItems: 'center',
}}>
<Image source={BG} style={styles.bg} resizeMode="cover" />
<Text style={styles.text}>{'Powered By'}</Text>
<Image source={CL} style={styles.logo} resizeMode="contain" />
</SafeAreaView>
);
}
}
const styles = StyleSheet.create({
bg: {
position: 'absolute',
width: ComponentStyles.WIDTH,
height: ComponentStyles.HEIGHT,
},
logo: {
position: 'absolute',
width: ComponentStyles.WIDTH * 1,
height: ComponentStyles.HEIGHT * 0.1,
borderRadius: ComponentStyles.HEIGHT * 0.4,
bottom: 2,
alignSelf: 'center',
},
text: {
position: 'absolute',
fontSize: ComponentStyles.WIDTH * 0.05,
fontFamily: 'berkshireswash-regular',
bottom: 65,
alignSelf: 'center',
color: ComponentStyles.COLORS.BLACK,
},
});
Still couldn't figure out the issue for this design issue.仍然无法弄清楚这个设计问题的问题。
Do you have any idea?你有什么主意吗?
Your view render item in splace screen I have changed safearea view design remove two properties from stylesheet您在 splace 屏幕中的视图渲染项目我已更改安全区域视图设计从样式表中删除两个属性
render() {
return (
<SafeAreaView
contentContainerStyle={{
flex: 1,
}}>
<Image source={BG} style={styles.bg} resizeMode="cover" />
<Text style={styles.text}>{'Powered By'}</Text>
<Image source={CL} style={styles.logo} resizeMode="contain" />
</SafeAreaView>
);
}
}
Also, change your image stylesheet bg另外,更改您的图像样式表bg
bg: {
flex: 1
width: ComponentStyles.WIDTH,
height: ComponentStyles.HEIGHT,
}
This is work for me I used style sheet of image like above code it works for me fine, hope this work for you这对我有用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.