如前所述,如果我在 react-native-router-flux 中使用自定义导航栏,并使用 NO 位置样式标记对其进行样式设置,那么导航栏将呈现在屏幕底部...
所以,我尝试使用位置设置样式:'absolute',顶部:0,右:0,左:0,我的导航栏消失了:(有什么建议吗?
路由器.js
<Scene
key="api"
hideNavBar={false}
navBar={HeaderWithIcon}
component={APITest}
/>
HeaderWithIcon.js
import React, {Component} from 'react';
import { View, Image, Text } from 'react-native';
import { menuStyles } from './styles';
class HeaderWithIcon extends Component {
constructor(props) {
super(props);
}
render() {
const icon =
require('../../assets/images/myImg.png');
return (
<View>
<View style={[menuStyles.view, this.props.style]}>
<Image source={icon} style={[menuStyles.icon, this.props.iconStyle]} />
</View>
</View>
);
}
};
export default HeaderWithIcon;
样式.js
import { HEADER } from '../../global/margins';
import { PRIMARY_COLOUR, SHADOW_COLOUR } from '../../global/colours';
export const menuStyles = {
view: {
flexDirection: 'row',
//height: HEADER.height,
width: null,
backgroundColor: PRIMARY_COLOUR,
alignItems: 'center',
justifyContent: 'center',
padding: 10,
// paddingTop: HEADER.padding,
shadowColor: SHADOW_COLOUR,
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.2,
position: 'absolute',
top: 0,
left: 0,
right: 0
},
icon: {
width: HEADER.icon,
height: HEADER.icon,
alignSelf: 'center'
}
};