導航螢屏時的默認螢屏影片是螢屏從右到左。在某些情況下,我希望螢屏在導航時執行不同的操作,例如從左到右或從下到上。導航時如何將螢屏影片更改為從螢屏左側到螢屏右側或從下到上?
我在這里提供了一個小吃示例,它準確地再現了我想要做的事情以及下面的一些代碼。
謝謝你的任何見解,我比你知道的更感激。
<Stack.Navigator
initialRouteName="Home">
<Stack.Screen name="Home" component= {Home} options={{headerShown: false}}/>
<Stack.Screen name="Screen2" component= {Screen2} options={{headerShown: false}}/>
</Stack.Navigator>
<TouchableOpacity onPress={() => this.props.navigation.navigate('Screen2')}>
<Text style={{fontSize: 20, fontWeight: 'bold', color: 'white'}}>
Press me to navigate, I want to be able to change the direction the screen comes in from, like left to right or bottom to top.
</Text>
</TouchableOpacity>
uj5u.com熱心網友回復:
您可以將cardStyleInterpolator屬性用于螢屏影片。在下面的示例中,頁面將從左向右滾動。
例如:
<Stack.Navigator
initialRouteName="Home"
screenOptions={{
cardStyleInterpolator: CardStyleInterpolators.forHorizontalIOS,
}}
>
<Stack.Screen name="Home" component= {Home} options={{headerShown: false}}/>
<Stack.Screen name="Screen2" component= {Screen2} options={{headerShown: false}}/>
</Stack.Navigator>
可以使用什么(cardStyleInterpolator):
forBottomSheetAndroid
forFadeFromBottomAndroid
forFadeFromCenter
forHorizontalIOS
forModalPresentationIOS
forNoAnimation
forRevealFromBottomAndroid
forScaleFromCenterAndroid
forVerticalIOS
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/433655.html
上一篇:在expo中洗掉對web的支持
