-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Customize Header Background Image #716
Comments
React-Navigation doesn't support this, as you have to wrap your content in an |
Do you have an example of how to do this? I'm finding the docs difficult to follow. Thanks |
I also would like to know how to add a header background image. |
+1 |
I'd also like to see an example of a custom header +1 |
Creating a custom header with an image is actually really simple. By wrapping the Header with a view and placing an absolute positioned image in that view, the image will scale to its parent size. Important is to set the const ImageHeader = props => (
<View style={{ backgroundColor: '#eee' }}>
<Image
style={StyleSheet.absoluteFill}
source={{ uri: 'https://upload.wikimedia.org/wikipedia/commons/3/36/Hopetoun_falls.jpg' }}
/>
<Header {...props} style={{ backgroundColor: 'transparent' }}/>
</View>
); And then use that component as header: const SimpleStack = StackNavigator({
Home: {
screen: MyHomeScreen,
},
}, {
navigationOptions: {
headerTitleStyle: { color: '#fff' },
header: (props) => <ImageHeader {...props} />,
}
}); Which would result in: |
This is my header it seems the tittle and headerRight is not working when i put custom header |
Try removing the styles from the container view in the ImageHeader and see if it works then. |
Can anyone advise on how to simple replace the headerTitle text with an Image. For us there is no need to fully replace the entire header, we just want to add an image instead of a title text for the header. Thanks. |
You can supply a React component as See this issue for a bit more info; #1302 |
@koenpunt How does your Header component look like? Do we need to create a custom Header component ourself or we could somehow get the header component react-navigation uses? Edited: |
@koenpunt Thanks for your solution. But it doesn't work well at V1.0.0-beta.19. |
Hi @angryBearLX , I have the same problem, do you find a solution for that? |
@angryBearLX You saved my life. |
EDIT Have it working now. I needed to import Header from react-navigation. For some reason I was creating another const variable called Header and using that. Silly me. Thanks everyone :) |
moved to website repo as this belongs in documentation: react-navigation/react-navigation.github.io#8 |
There is a prop named headerBackground can do the work. })` |
I am using React-Navigation for routing in a React Native app and was wondering how I can show a background image in the header as opposed to a background color. For a colour I can use the header object on NavigationOptions, but how can I nest an image in here?
The text was updated successfully, but these errors were encountered: