Skip to content

Instantly share code, notes, and snippets.

@watanabeyu
Created February 9, 2018 06:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save watanabeyu/c7e9546e86527faecb12e5407436e465 to your computer and use it in GitHub Desktop.
Save watanabeyu/c7e9546e86527faecb12e5407436e465 to your computer and use it in GitHub Desktop.
react-navigationのtabNavigatorの背景色を変更する
const tabNavigator = TabNavigator(
{
Home: { screen: HomeScreen },
Search: { screen: HomeScreen }
},
{
tabBarOptions: {
showLabel: false,
activeTintColor: '#333',
inactiveTintColor: '#bbb',
},
tabBarComponent: TabBar,
tabBarPosition: 'bottom',
animationEnabled: false,
swipeEnabled: false,
},
);
// check state.index
const TabBar = (props) => {
const { navigationState } = props;
let newProps = props;
if (navigationState.index === 0) {
newProps = Object.assign(
{},
props,
{
style: {
backgroundColor: 'rgba(0,0,0,0.1)',
position: 'absolute',
bottom: 0,
left: 0,
right: 0
},
activeTintColor: '#fff',
inactiveTintColor: '#bbb',
},
);
}
return <TabBarBottom {...newProps} />;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment