我正在制作加载屏幕,并将其设置为绝对位置整个屏幕。但是,当使用react-navigation
时,它似乎没有涵盖标题。有没有办法将我的组件置于导航库的头部组件之上?反应导航导航标题顶部的绝对位置
当您使用react-navigation
时,您可以为该屏幕配置标题。通常,当您导航到屏幕时,您在该屏幕内呈现的任何代码都会自动放置在导航标题下方。但是,我希望我的组件占据整个屏幕并覆盖标题。我想要保持头部,但我想用不透明度来掩饰它。这可能吗?
const navigationOptions = {
title: "Some Title",
};
const Navigator = StackNavigator(
{
First: { screen: ScreenOne },
Second: { screen: ScreenTwo },
...otherScreens,
},
{
transitionConfig,
navigationOptions, //this sets my header that I want to cover
}
);
这里是我的loader.js
const backgroundStyle = {
opacity: 0.5,
flex: 1,
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
zIndex: 1,
};
const Loading =() =>
<View style={backgroundStyle}>
<PlatformSpinner size="large" />
</View>;
在ScreenOne.js
class ScreenOne extends Component {
render(){
if(loading) return <Loading/>;
return (
//other code when not loading that is placed under my header automatically
)
}
}
https://snack.expo.io/SyZxWnZPZ
示例代码,请你的你有什么和你想达到什么样的一个例子详细点吗? – lilezek
当然,增加更多 – Turnipdabeets
为什么你的宽度和高度是在视口单位和百分比单位? – lilezek