Строка состояния Iphone 5 закрывается React Native - PullRequest
0 голосов
/ 23 октября 2018

Мой код работает нормально на большинстве iPhone, но на Iphone 5 строка состояния была закрыта представлением, я не знаю, как ограничить представление в Iphone 5, только если я использовал наверху поле представления, это выглядитстранно в других айфонах

componentWillMount() {
        this.startHeaderHeight = 45
        this.marginTopHeader = 0
        this.iconMargin = 9
        if (Platform.OS == 'android') {
            this.startHeaderHeight = 30 + StatusBar.currentHeight
            this.marginTopHeader = 23 + this.marginTopHeader
            this.iconMargin = this.iconMargin
        }

    }
    render() {
        var width = Dimensions.get('window').width - 128;
        var height = Dimensions.get('window').height;
        return (
            <SafeAreaView  style={{
                height: this.startHeaderHeight, flexDirection: 'row',
                borderBottomColor: '#ddd', backgroundColor: '#3A3658', marginTop: this.marginTopHeader
            }} >

                <Icon
                    lightTheme
                    style={{ marginLeft: 8, marginRight: 5, marginTop: this.iconMargin, color: 'white' }} size={25} name="ios-menu" onPress={() => {
                        this.props.draw();
                    }}    />
            <View style={{position: 'absolute', right: 7}}>

                <Icon style={{ color: '#fff',marginTop: this.iconMargin ,padding:0,}} size={25} name="ios-cart" onPress={() => {
                        this.props.cart();
                    }}>
                   <Text style={{color:'red', fontWeight:'bold', fontSize:10}}>{this.props.cartItemCount}</Text>

                    </Icon>

</View>
            </SafeAreaView >

1 Ответ

0 голосов
/ 23 октября 2018

Вы можете попробовать написать так.

<View style={{flex: 1, backgroundColor: 'white'}} >
        {/* header */}
        <View style={{paddingTop: system.ios.x ? 22 : 0}}>
          <View style={{
            height: Platform.select({ios: 64, android: 44}),
            backgroundColor: 'white',
            justifyContent: 'flex-end'
          }}>
          `enter code here`
          </View>
        </View>
</View>
...