0

我想用刷卡器在标题后面添加多个图像。我尝试使用Native-baseand来实现这个react-native-swiper。但是,结果如下。

在此处输入图像描述

以下是我的代码

<View style={{flex:1, elevation:2}}>
                    <Swiper style={StyleSheet.flatten( {backgroundColor: '#fff'})}>
                    <ImageBackground
                        source={require('../../img/auth_background.png')}
                        style={this.styles.backgroundStyle}
                        imageStyle={this.styles.backgroundImage}
                    >
                        <Header style={{
                            marginTop: StatusBar.currentHeight,
                            backgroundColor: 'transparent',
                            justifyContent: 'center',
                            alignItems: 'center',
                        }}>
                            <StatusBar
                                backgroundColor={Colors.statusBar}
                                barStyle="light-content"
                            />
                            <Left>
                                <Button transparent onPress={this.handleBackButtonClick} small={true}>
                                    <Icon name='ios-arrow-back' size={30} color={Colors.textWhite}/>
                                </Button>
                            </Left>
                            <Body/>
                            <Right/>
                        </Header>
                    </ImageBackground>
                        <ImageBackground
                            source={require('../../img/auth_background.png')}
                            style={this.styles.backgroundStyle}
                            imageStyle={this.styles.backgroundImage}
                        >
                            <Header style={{
                                marginTop: StatusBar.currentHeight,
                                backgroundColor: 'transparent',
                                justifyContent: 'center',
                                alignItems: 'center',
                                borderBottomWidth: 0, shadowOffset: {height: 0, width: 0},
                                shadowOpacity: 0, elevation: 0
                            }}>
                                <StatusBar
                                    backgroundColor={Colors.statusBar}
                                    barStyle="light-content"
                                />
                                <Left>
                                    <Button transparent onPress={this.handleBackButtonClick} small={true}>
                                        <Icon name='ios-arrow-back' size={30} color={Colors.textWhite}/>
                                    </Button>
                                </Left>
                                <Body/>
                                <Right/>
                            </Header>
                        </ImageBackground>
                    </Swiper>
</View>

我想修复标题,这样它就不会与图像一起滑动。谁能帮我这个?提前致谢。

4

3 回答 3

0

android 中的 React-Native-Swiper 会在没有显示 swiper 高度和宽度时显示空白内容。请添加固定的高度和宽度以查看或添加到 swiper

于 2018-10-10T06:15:08.737 回答
0

保持你的Header外在Swiper并确定其位置absolute

<Header style={{
        marginTop: StatusBar.currentHeight,
        backgroundColor: 'transparent',
        justifyContent: 'center',
        alignItems: 'center',
        position:'absolute',
        top:0,
        left:0
}}>
于 2018-10-10T11:10:56.973 回答
0

我使用zIndexand找到了解决方案positionheader我想在使用 native-base和containerwith时存在一些问题zIndex

<View style={{flex: 1}}>
                    <View style={{flex:1, zIndex: 2, position: 'absolute', marginTop: StatusBar.currentHeight, marginLeft:'2%'}}>
                       <Button iconLeft transparent>
                               <Icon name='ios-arrow-back' size={30} color={Colors.textWhite}/>
                       </Button>
                    </View>
                    <View style={{width: '100%', height: '50%', zIndex: 1, position: 'absolute'}}>
                        <Swiper style={StyleSheet.flatten( {backgroundColor: '#fff',zIndex:1, flex:1})}>
                            <ImageBackground
                                source={require('../../img/auth_background.png')}
                                style={this.styles.backgroundStyle}
                                imageStyle={this.styles.backgroundImage}
                            >

                            </ImageBackground>
                            <ImageBackground
                                source={require('../../img/auth_background.png')}
                                style={this.styles.backgroundStyle}
                                imageStyle={this.styles.backgroundImage}
                            >
                            </ImageBackground>
                        </Swiper>
                    </View>

于 2018-10-15T09:04:11.447 回答