react-native - 在反应本机导航中自定义标题
问题描述
在我的应用程序主屏幕中,我想自定义标题以使左右两个图标可以使用:
<HomeStack.Screen
name="Home"
component={HomeScreen}
options={{
title: '',
headerLeft: () => (
<View style={{ marginLeft: 10 }}>
<Icon.Button
name="ios-menu"
size={25}
color="#000000"
backgroundColor={COLORS.primary}
onPress={() => navigation.openDrawer()}
/>
</View>
),
headerRight: () => (
<View style={{ marginLeft: 10 }}>
<Icon.Button
name="location-outline"
size={25}
color="#000000"
backgroundColor={COLORS.primary}
onPress={() => navigation.openMap()}
/>
</View>
),
}} />
</HomeStack.Navigator>
我想添加其他内容,但要位于中心,这将根据我的需要进行定制,但我不知道如何实现它,因为没有任何东西叫做 headerCneter:
解决方案
也许您可以利用堆栈导航器中的标题选项?然后,您可以使用路由参数从那里自定义您的标头。
推荐阅读
- azure-machine-learning-service - Azure ML SDK DataReference - 文件模式 - 许多文件
- java - 用于自定义游戏中角色可能状态的设计模式
- c# - C# 无法使用 MySql.Data.MySqlClient 连接 mariaDB
- regex - 匹配列中的文本值并对另一列中匹配的值执行函数
- python - 如何在 PyQt5 (5.13) 中启用 macOS 暗模式
- html - Flex 元素在不需要时增长,在空间用完时不缩小
- python - 使用 ElelemtTree 从 XML 标记中提取作者姓名
- javascript - 如何使用获取请求的结果更新文本框
- javascript - 可以做些什么来使需要评估表达式安全的 javascript 函数?
- python - Pandas:如何按列值添加新的索引级别