我正在simulator.app上进行iOS模拟,打开vscode,直到几个小时后才发现dat代码有什么问题,我尝试了10多种解决方案。。。还有同样的问题
我试着把我最上面栏中的标题左对齐。就这么简单。
我正在开发一个新版本,我刚刚为这个项目初始化。
为了快速明了:headerTitleAlign在我的应用程序上不起作用。
目前我的代码是:
<Stack.Navigator screenOptions={{
headerStyle :{
backgroundColor : Colors.light.tint,
},
headerTintColor: Colors.light.background,
headerTitleStyle: {
fontWeight:'bold',
}
}}>
在这种情况下,我能找到的大部分解决方案是将我的headerTitleAlign设置在标题样式上:
<Stack.Navigator screenOptions={{
**<!-- PUT MY CODE HERE -->**
headerStyle :{
backgroundColor : Colors.light.tint,
},
headerTintColor: Colors.light.background,
headerTitleStyle: {
fontWeight:'bold',
}
}}>
所以我做了:
<Stack.Navigator screenOptions={{
alignHeaderTitle : 'left',
headerStyle :{
backgroundColor : Colors.light.tint,
},
headerTintColor: Colors.light.background,
headerTitleStyle: {
fontWeight:'bold',
}
}}>
但是dat不起作用。我的意思是,我的头衔是保持在中心。我听说它是在iOS上默认设置的,我该怎么修改它?
我测试的一些部分:
<Stack.Navigator screenOptions={{
defaultNavigationOptions: {
headerTitleAlign: 'left'},
headerStyle :{
backgroundColor : Colors.light.tint,
},
headerTintColor: Colors.light.background,
headerTitleStyle: {
fontWeight:'bold',
}
}}>
<Stack.Navigator screenOptions={{
headerStyle :{
backgroundColor : Colors.light.tint,
},
headerTitleAlign: 'left',
headerTintColor: Colors.light.background,
headerTitleStyle: {
fontWeight:'bold',
}
}}>
<Stack.Navigator screenOptions={{headerTitleAlign: 'left',
headerStyle :{
backgroundColor : Colors.light.tint,
},
headerTintColor: Colors.light.background,
headerTitleStyle: {
fontWeight:'bold',
}
}}>
<Stack.Navigator screenOptions={{
title: "Title left",
headerTitleAlign:'left',
headerTitleStyle: {
textAlign:"left",
flex:1
},
headerStyle :{
backgroundColor : Colors.light.tint,
},
headerTintColor: Colors.light.background,
headerTitleStyle: {
fontWeight:'bold',
}
}}>
etcetera etcetera
所以我想它可能在这部分代码之外,也许它默认设置在!重要到新版本?
我在<Stack.Screen name="Root"
上也试过同样的方法但仍然存在同样的问题。
这个问题来自这个视频的一开始:
https://www.youtube.com/watch?v=EvSUJ5lUcBw&t=1705s
非常感谢你的帮助,伙计们
我想我找到了答案,React navigation在文档中表示:文件屏幕
有黑客吗?(它完全破坏了我的应用程序的UI:D
您可以通过使用headerLeft函数来实现这一点
screenOptions={{
title: null,
headerStyle: {
backgroundColor: Colors.light.tint,
},
headerTintColor: Colors.light.background,
headerLeft: () => (
<View>
<Text
style={{ color: Colors.light.background, fontWeight: "bold" }}
>
Whatsapp
</Text>
</View>
),
}}