【问题标题】:How to make custom header bar in navigation 5?如何在导航 5 中制作自定义标题栏?
【发布时间】:2020-05-03 12:06:21
【问题描述】:

我想创建自定义标题栏,因为产品屏幕到产品名称屏幕我想在标题栏中显示产品名称

【问题讨论】:

    标签: react-native react-native-android react-native-ios react-native-flatlist react-native-navigation


    【解决方案1】:

    试试这个, 更多帮助:- https://reactnavigation.org/docs/headers/

    function HomeScreen({ navigation }) {
      return (
        <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
          <Text>Home Screen</Text>
          <Button
            title="Go to Profile"
            onPress={() =>
              navigation.navigate('Profile', { name: 'Custom profile header' })
            }
          />
        </View>
      );
    }
    
    function ProfileScreen({ navigation }) {
      return (
        <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
          <Text>Profile screen</Text>
          <Button title="Go back" onPress={() => navigation.goBack()} />
        </View>
      );
    }
    function App() {
      return (
        <NavigationContainer>
          <Stack.Navigator>
            <Stack.Screen
              name="Home"
              component={HomeScreen}
              options={{ title: 'My home' }}
            />
            <Stack.Screen
              name="Profile"
              component={ProfileScreen}
              options={({ route }) => ({ title: route.params.name })}
            />
          </Stack.Navigator>
        </NavigationContainer>
      );
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-09
      • 2020-09-16
      • 2011-06-24
      • 1970-01-01
      • 1970-01-01
      • 2020-05-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多