【问题标题】:React native imageBackground not full screen反应原生图像背景不是全屏
【发布时间】:2019-04-24 21:01:13
【问题描述】:

我创建了一个 Wallpaper.js,我的背景图片在哪里。但是,它没有在我的模拟器上全屏显示。

我的 Wallpaper.js

import React, { Component } from 'react';
import { StyleSheet, ImageBackground } from 'react-native';

import bgSrc from '../../images/wallpaper.png';

export default class Wallpaper extends Component {
  render() {
    return (
      <ImageBackground style={styles.picture} source={bgSrc}>
        {this.props.children}
      </ImageBackground>
    );
  }
}

const styles = StyleSheet.create({
  picture: {
    flex: 1,
    width: null,
    height: null,
    resizeMode: 'cover',
  },
});

我在我的登录页面中称这个壁纸为:

export default class LoginScreen extends Component {
  render() {
    return (
      <Wallpaper>

      </Wallpaper>
    );
  }
}

结果是顶部有一个空白区域。为什么不是全屏?

谢谢

【问题讨论】:

  • 这可能是导航使用的默认标题。如果是,则使用静态导航选项在组件中隐藏此标题

标签: react-native imagebackground


【解决方案1】:

您必须检查导航器堆栈的 headerMode。它必须是“模态”

【讨论】:

    猜你喜欢
    • 2018-05-04
    • 2022-10-23
    • 2016-12-31
    • 2020-07-06
    • 1970-01-01
    • 2017-05-28
    • 2023-03-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多