【发布时间】:2017-01-11 13:38:07
【问题描述】:
如前所述,如果我在 react-native-router-flux 中使用自定义导航栏,并使用 NO 位置样式标记对其进行样式设置,那么导航栏将呈现在屏幕底部...
所以,我尝试使用 position: 'absolute', top: 0, right:0, left: 0 设置样式并且我的导航栏消失了:(有什么建议吗?
Router.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;
styles.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'
}
};
【问题讨论】:
标签: reactjs react-native navbar react-redux react-native-router-flux