React Native - 无法将图标放在图像顶部

React Native - Can't place icon on top of image

我试图在图像上放置一个图标,但它所做的只是将图像推到页面下方。

这是目前的样子:

我正在尝试将蓝色后退箭头放在该图像的顶部,如您所见。

这是我的标记的样子:

<ScrollView style={ styles.container }>
  <View style={ styles.coverImageContainer }>
    <Image
      style={ styles.coverImage }
      source={ require('./img.jpg') }
    >
      <View>
        <Ionicons name="ios-arrow-back" color="#4F8EF7" size={25} />
      </View>
    </Image>
  </View>
  ...

这是我的风格:

container: {
  backgroundColor: '#f9f9f9',
  flex: 1,
},

coverImageContainer: {
  backgroundColor: '#000',
},

coverImage: {
  width: null,
  height: 170,
  resizeMode: 'cover',
  opacity: 0.7,
  flex: 1,
},

我做错了什么?

如果我去掉图标,图像会显示我想要的样子,但我也希望在它上面有后退按钮图标。这是没有图标的样子:

状态栏始终可见,即使您在后退按钮上使用 position:'absolute'; zIndex: 99999,也有两种方式:

  1. 通过在渲染中添加 <StatusBar hidden={true}/> 来删除状态栏
  2. 添加marginTop: 22让箭头稍微向下移动

绝对定位 Icon 组件。

<Ionicons name="ios-arrow-back" color="#4F8EF7" size={25} style={{ position: 'absolute', top: 30, left: 10 }} />