react-Native:iOS 上的背景图片无法覆盖所有屏幕

react-Native: background image on iOS has cannot cover all the screen

背景图片在 iOS 设备上没有填满整个屏幕,尽管尝试了不同的样式选项。而在 Android 设备上它看起来不错并且填充了所有背景 space。

我在 iPhone6 设备上遇到了同样的问题,在 iPhone 11 模拟器上也是如此。左右两侧似乎有背景图像未覆盖的白色边缘,但这在 android 设备上不会发生。

这是iOS和android两个模拟器的并排图片,iOS在右边。

我尝试使用 属性 resizeMode 样式,其值为 'cover'、'stretch'、'contain' 等,但其中 none 似乎有所作为..这是代码:

import React from 'react';
import { Text, View, Platform, ImageBackground } from 'react-native';
import { Button } from 'native-base'

var myBackground = require('./assets/icons/landing.jpg')

export default function App() {
  return (
    <View style={styles.container}>
      <ImageBackground
        source={myBackground}
        style={styles.imageStyle}
        >
        <View style={styles.viewStyle}>
          <Text
            style={styles.titleStyle}
          >Welcome to pokeSearch</Text>
          <Button
            block={true}
            style={styles.buttonStyle}
            onPress={() => { }}
          >
            <Text style={styles.buttonText}>Start Searching</Text>
          </Button>
        </View>
      </ImageBackground>


    </View>
  );
}

const styles = {
  container: {
    flex: 1,
    // marginTop: Platform.OS === "android" ? 20 : 0,
    justifyContent: 'center',
    alignItems: 'center'

  },
  buttonOuterLayout: {
    flex: 1,
    flexDirection: 'column',
    justifyContent: 'center',
    alignItems: 'center',


  },
  buttonLayout: {
    // marginTop: 10,
    // paddingRight: 10,
    // paddingLeft: 10

  },
  viewStyle: {
    flex: 1,
    flexDirection: 'column',
    justifyContent: 'center',
    alignItems: 'center'
  },
  titleStyle: {
    fontSize: 30,
    color: 'blue',
    alignItems: 'center'

  },
  imageStyle: {
    // flex: 1,
    width: null,
    height: null,
    resizeMode: 'contain'

    // justifyContent: 'flex-end',
    // alignItems: 'center'
  },

  buttonStyle: {
    margin: 10

  },
  buttonText: {
    color: 'white'
  }
}

我希望背景图像像在 android 上一样覆盖 iOS 上的背景。

解决方法是改变背景图片样式如下:

imageStyle: {
    flex: 1,
    width: '100%',
    height: '100%',
    resizeMode: 'cover'
}

所有功劳归功于 matPag 和