react-native开发需时肯定有tab的切换,或者页面的转调,当然用RN自身的Navigator 也可以但是也不是那么方便react-navigation 就能满足很多大部分需求,如下图的三种切换方式,下面就说下TabNavigator 和StackNavigator的应用,才踏的一个坑,还是太年轻呀,横刀一撸!!!!
主要的界面 用tab 切换即是TabNavigator, 切换如下图
一共四个页面当然配置就如下咯
// 两个参数 routeConfigs: NavigationRouteConfigMap, config: TabNavigatorConfig = {}
// 一个route对应的页面和tab图标, 一个切换的样式整个tab栏的样式
//tab
export const AppNavigator = TabNavigator({
Hotshow: {screen: hotshow, navigationOptions: {
tabBarLabel: '热映',
tabBarIcon: ({ tintColor, focused }) => (
<Image resizeMode='contain'
source={require('../icon/icon_hot.png')}
style={[style.footImage, {tintColor: tintColor}]}
/>
)
}},
Usshow: {screen: usshow, navigationOptions: {
tabBarLabel: '北美',
tabBarIcon: ({ tintColor, focused }) => (
<Image style={[style.footImage, {tintColor: tintColor}]}
resizeMode='contain'
source={require('../icon/icon_us_normal.png')}
/>
)
}},
Soonshow: {screen: soonshow, navigationOptions: {
tabBarLabel: '近期',
tabBarIcon: ({ tintColor, focused }) => (
<Image style={[style.footImage, {tintColor: tintColor}]}
resizeMode='contain'
source={require('../icon/icon_soon_normal.png')}
/>
)}
},
Nearcinemas: {screen: nearcinemas, navigationOptions: