react-native 之react-navigation createMaterialTopTabNavigator设置

在配置navigationOptions 时可以这样,设置标题和图片icon

navigationOptions:{
          tabBarLabel:(({tintColor,focused})=>{
            return (
              <View>
                <Text style={(item.label=='计划')?styles.labelStyle:styles.noniconlabelStyle}>{item.label}</Text>
              </View>
            )
          }),
          tabBarIcon:(({tintColor,focused})=> {
            return(
                  <View>
                    <Image
                      source={item.icon}
                      style={(item.label=='计划')?styles.iconStyle:styles.noniconStyle}
                    />
                  </View>
              )
          })
        }

react-navigation 的

createMaterialTopTabNavigator 

API 可参考 官网 https://reactnavigation.org/docs/zh-Hans/material-top-tab-navigator.html

也可参考:https://www.jianshu.com/p/86f37fb7fd02 中文介绍的很详细

猜你喜欢

转载自www.cnblogs.com/liuw-flexi/p/12263171.html