React Navigation演示模式-禁用父屏幕缩小(iOS)



我正在尝试制作一个底部模态,它从底部向上滑动,具有透明背景,并且可以向下滑动(与Instagram的各种底部模态完全相同(。我几乎可以用实现这一点

<Stack.Screen
name="testModal"
component={ChatAttachments}
options={{
headerShown: false,
headerTransparent: true,
presentation: "modal",
cardOverlayEnabled: true,
gestureDirection: "vertical",
gestureResponseDistance: 500,
cardStyle: {
backgroundColor: "transparent",
opacity: 1,
},
}}
/>

但是,有没有办法禁止父屏幕缩小?

另一种选择可能是使用presentation: "transparentModal",但这并不能给我向下滑动的能力。

在选项中尝试gestureEnabled: true,;另外,对于滑动效果,你需要手动添加一个动画样式,比如这个:

cardStyleInterpolator: ({current: {progress}}) => {
const opacity = progress.interpolate({
inputRange: [0, 1],
outputRange: [0, 1],
extrapolate: 'clamp',
});
return {cardStyle: {opacity}};
},

最新更新