自定义导航返回按钮颜色,参考文档找了半天没解决,下面是我的比较笨的解决办法,如果您有简单的办法麻烦评论告知一下。
版本信息
"@react-navigation/native": "^5.7.3", "@react-navigation/stack": "^5.9.0", "react-native": "0.63.2",
设置颜色方法
import {HeaderBackButton} from '@react-navigation/stack';
<Stack.Screen
name="ThemeScreen"
component={ThemeScreen}
options={({navigation})=>({
title: '主题设置', headerShown: true,
headerStyle: {
backgroundColor: backgroundColor,
},
headerTitleStyle: {
color: '#fff',
},
headerLeft: (props) => (
<HeaderBackButton
{...props}
tintColor='#fff'
onPress={() => {
navigation.goBack()
}}
/>
),
})}
/>
<HeaderBackButton
{...props}
tintColor='#fff'
onPress={() => {
navigation.goBack()
}}
/>
绿色部分是设置颜色的地方。
效果如下:
这样的写法略显繁琐,正在找简单的实现办法