San*_*hra 6 react-native react-native-router-flux react-native-ios
我正在使用react-native-router-flux v4.0库来显示react-native中的导航栏.
我在这里创建了一个自定义导航栏.
这是我的代码:
_renderLeft() {
return (
<TouchableOpacity
style={{justifyContent: 'flex-start', alignItems: 'flex-start', alignSelf: 'flex-start'}}
onPress={Actions.pop}>
<Image
style={{width: 24, height: 24}}
resizeMode="contain"
source={require('../../assets/images/ico_swipe.png')}></Image>
</TouchableOpacity>
)
}
_renderMiddle() {
return (
<View style={[styles.navBarTitleView]}>
<Text style={[styles.navBarTitle]}>{this.props.title}</Text>
</View>
)
}
_renderRight() {
return (
<TouchableOpacity
style={{justifyContent: 'flex-start', alignItems: 'flex-start', alignSelf: 'flex-start'}}
onPress={Actions.pop}>
<Image
style={{width: 24, height: 24}}
resizeMode="contain"
source={require('../../assets/images/ico_home.png')}></Image>
</TouchableOpacity>
)
}
render() {
StatusBar.setBarStyle('light-content', true);
return (
<Header style={[styles.container]}>
<Left style={{flex: 1}}>
{this._renderLeft()}
</Left>
<Body style={{flex: 3}}>
<Title style={styles.navBarTitle}>{this.props.title}</Title>
</Body>
<Right style={{flex: 1}}>
{this._renderRight()}
</Right>
</Header>
)
}
Run Code Online (Sandbox Code Playgroud)
这是我的风格:
const styles = StyleSheet.create({
container: {
backgroundColor: AppColors.colorToolBar,
elevation:0
},
navBarTitleView: {
flex: 2,
},
navBarTitle: {
fontSize: 20,
fontFamily: AppStyles.fontFamilyMedium,
color: AppColors.white,
alignSelf: 'center'
},
menuItem:{
flex: 1, flexDirection: 'row', padding: 20
},
menuTitle:{flex: 20, justifyContent: 'flex-start', alignItems: 'center',
alignSelf: 'flex-start'},
menuNextArrow:{flex: 1}
Run Code Online (Sandbox Code Playgroud)
});
我在这里使用它:
<Stack key="Key" hideTabBar>
<Scene key="Key"
navBar={MyCustomNavBarLocation}
component={myFileLocation}
title="Round 1"
onLeft={Actions.pop}
BackHandler={Actions.pop}
back
/>
</Stack>
Run Code Online (Sandbox Code Playgroud)
我在Android中正确得到它:
但在Iphone中它不合适:
这里如果你看到第二张图片你在导航栏和TimeRemaining视图之间看到一条灰色线我想删除它.
谢谢
问题出在NativeBase的 Header组件中 .底部边框线来自Header样式.所以根据这里提出的问题,使用,
<Header noShadow={true} hasTabs={true}
Run Code Online (Sandbox Code Playgroud)
解决这个问题.
这是较晚但更准确的答案,在路由器中添加此行以管理影子:
<Router
navigationBarStyle={{ ...Platform.select({
ios: {
// marginTop: StatusBar.currentHeight
elevation: 0,
shadowOpacity: 0,
borderBottomWidth: 0,
}
})
}}
>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5396 次 |
| 最近记录: |