2017-07-11 49 views
2

如何添加我自己的标题组件,以便我可以在nav中添加图像?react-navigation添加自定义标题

我设置我的标题这样,我可以设置组件的权利和左,但如何添加一个居中的图像到我的导航?

const headerStyle = { 
    paddingHorizontal: theme.metrics.mainPadding, 
    paddingTop: 2, 
    paddingBottom: 2, 
    backgroundColor: theme.colors.purple, 
    justifyContent: 'center', 
}; 

const headerTitleStyle = { 
    textAlign: 'center', 
    alignSelf: 'stretch', 
    alignItems: 'center', 
    ...theme.fontStyles.appBarTitle, 
}; 

const headerRight = <Text>logo here</Text>; 
const headerLeft = <Text>text here</Text>; 

export default { 
    title, 
    headerStyle, 
    headerTitleStyle, 
    headerRight, 
    headerLeft, 
}; 

回答

0

您必须在每个组件中设置标题可见性以隐藏标题。

static navigationOptions = { 
header: { 
    visible: false, 
} 
}; 

REACT航海改变了API用于从v1.0.0-beta.9隐藏首部。改为使用header: null

static navigationOptions = { 
header: null 
}; 
+0

谢谢,我如何添加一个头,一旦我已经隐藏的默认吗? – Bomber

+0

使用'native-base',您可以在'

...
'元素之间添加您的代码。 –