如何在反馈原生的屏幕截图上创建菜单?
答案 0 :(得分:2)
你可以设置backgroundColor:'rgba(0,0,0,0.2)'。
<Modal
animationType={"slide"}
transparent={false}
visible={this.state.modalVisible}
onRequestClose={() => {alert("Modal has been closed.")}}
>
<View style={{flex: 1,backgroundColor: 'rgba(0,0,0,0.2)'}}>
<View style ={{flex:1, alignItems: 'center', justifyContent: 'center'}}>
<View style={{backgroundColor: '#ffffff', width: 300, height: 300}}>
<Text>Hello World!</Text>
</View>
<TouchableHighlight
style={{backgroundColor: '#ffffff', width: 300, height: 40, marginTop: 40}}
onPress={() => {this.setModalVisible(!this.state.modalVisible)}}
>
<Text>Hide Modal</Text>
</TouchableHighlight>
</View>
</View>
</Modal>
答案 1 :(得分:2)
对于iOS而言,有一个名为ActionSheetIOS的组件,您可以这样调用它:
ActionSheetIOS.showActionSheetWithOptions(
{
options: ["Cancel", ...options],
title: "Select something",
message: "Some description",
cancelButtonIndex: 0
},
index => {
// do something with the selected index
const listIndex = index - 1;
if (index > 0) {
this.setState({ selectedIndex: listIndex });
}
}
);
答案 2 :(得分:0)
仅在iOS中
import { StyleSheet, Text, ActionSheetIOS } from "react-native";
...
OptionButton() {
let BUTTONS = ["Compartir", "Reportar", "Cancel"];
ActionSheetIOS.showActionSheetWithOptions(
{
title: "Opciones",
tintColor: "#242424",
options: BUTTONS,
cancelButtonIndex: 2,
destructiveButtonIndex: 1
},
buttonIndex => {
switch (buttonIndex) {
case 0:
this.shareImage();
break;
case 1:
this.reportImage();
break;
}
}
);
}