我很难将任何具有固定位置(浮动)的 UI 元素放置在模态内容超过屏幕高度的反应原生模态上。Flash 消息/小吃栏等也会出现类似的问题。它们呈现在模式内容的顶部/底部(如果滚动则不可见),而不是显示在页面的顶部/底部。我使用 react-native-paper 的 FAB 创建了一个示例来演示这一点。链接在这里 - https://snack.expo.io/PnX5RCE1_?
示例代码:
import * as React from 'react';
import { StyleSheet, View, Modal } from 'react-native';
import { FAB } from 'react-native-paper';
import { Container, Header, Body, Title, Content, ListItem, Text, Icon, Right } from 'native-base';
const renderModal = () : React.ReactElement<any> => {
return(
<Modal
animationType="fade"
visible={true}>
<Container>
<Header>
<Body>
<Title>Alert</Title>
</Body>
<Right>
<Icon name="closecircleo" type="AntDesign"></Icon>
</Right>
</Header>
<Content style={{padding: 10}}>
<Text>Adding a lot of text to make the modal content go out of screen height</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text><Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text><Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text><Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<Text>Some Text Here</Text>
<FAB
style={styles.fab}
small
icon="plus"
onPress={() => console.log('Pressed')}
/>
</Content>
</Container>
</Modal>
);
}
const MyComponent = () => (
<View>
{renderModal()}
</View>
);
const styles = StyleSheet.create({
fab: {
position: 'absolute',
margin: 16,
right: 0,
bottom: 0,
},
})
export default MyComponent;