Ima*_*ehi 6 android ios react-native react-navigation
我有一个反应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',
}
}
}
);
Run Code Online (Sandbox Code Playgroud)
现在我想为Tabs颜色使用线性渐变,但是我找不到任何方法!...怎么可能?我该如何使用此标签内的标签:
<LinearGradient colors={['#EF7D2F', '#C8191A']}>..here..</LinearGradient>
Run Code Online (Sandbox Code Playgroud)
您应该使用以下方法为您的选项卡添加自定义视图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',
}
}
}
);
Run Code Online (Sandbox Code Playgroud)
例如 TabBar 是这样的组件:
const TabBar=(props)=> {
return (
<LinearGradient colors={['#EF7D2F', '#C8191A']}>..here..
</LinearGradient>
);
}
Run Code Online (Sandbox Code Playgroud)
你可以用这个作为参考
| 归档时间: |
|
| 查看次数: |
169 次 |
| 最近记录: |