推荐:React Native底部抽屉组件——Bottom Sheet
warning:
这篇文章距离上次修改已过204天,其中的内容可能已经有所变动。
import React from 'react';
import { View, Text, StyleSheet, Dimensions } from 'react-native';
import BottomSheet from 'react-native-bottomsheet-view';
const screenHeight = Dimensions.get('window').height;
const BottomDrawer = () => {
return (
<BottomSheet
snapPoints={[screenHeight - 150, 0]}
borderRadius={10}
renderContent={() => (
<View style={styles.contentContainer}>
<Text>这里是底部抽屉的内容</Text>
</View>
)}
/>
);
};
const styles = StyleSheet.create({
contentContainer: {
backgroundColor: 'white',
padding: 20,
},
});
export default BottomDrawer;
这段代码展示了如何在React Native应用中使用react-native-bottomsheet-view
这个第三方库来创建一个可以从底部拖拽的抽屉组件。代码中定义了一个名为BottomDrawer
的组件,该组件使用BottomSheet
来渲染底部抽屉,并通过snapPoints
属性定义了抽屉可以展开的高度。renderContent
属性用于渲染抽屉内部的内容,这里简单地显示了一个文本。
评论已关闭