我有一个反应tabnavigator
,它是从ReactNavigation(v2)
组件中使用的:
const Tab = createMaterialTopTabNavigator({
Nearest: {
screen: Nearest, navigationOptions: {
tabBarLabel: 'myprofile'
}
},
Recomanded: {
screen: Recomanded, navigationOptions: {
tabBarLabel: 'recomanded'
}
},
Home: {
screen: Hotest, navigationOptions: {
tabBarLabel: 'hotest'
}
},
},
{
tabBarOptions: {
labelStyle: {
fontSize: 12,
fontFamily:"IRANSans"
},
tabStyle: {
backgroundColor: '#ef6102',
}
}
}
);
现在我想对Tabs颜色使用线性渐变,但是我找不到任何方法来实现它!...怎么可能?我该如何使用此标签内的标签:
<LinearGradient colors={['#EF7D2F', '#C8191A']}>..here..</LinearGradient>
答案 0 :(得分:0)
您应该使用tabBarCompontent
为标签添加自定义视图:
const Tab = createMaterialTopTabNavigator({
Nearest: {
screen: Nearest, navigationOptions: {
tabBarLabel: 'myprofile'
}
},
Recomanded: {
screen: Recomanded, navigationOptions: {
tabBarLabel: 'recomanded'
}
},
Home: {
screen: Hotest, navigationOptions: {
tabBarLabel: 'hotest'
}
},
},
{
tabBarComponent:(props)=>{
return(<TabBar {...props}></TabBar>)},<<<<<<<look here<<<<<<<<
tabBarOptions: {
labelStyle: {
fontSize: 12,
fontFamily:"IRANSans"
},
tabStyle: {
backgroundColor: '#ef6102',
}
}
}
);
例如TabBar是这样的组件:
const TabBar=(props)=> {
return (
<LinearGradient colors={['#EF7D2F', '#C8191A']}>..here..
</LinearGradient>
);
}
您可以使用this作为参考