类型
TouchableWithoutFeedback
:点击之后没有任何效果TouchableHighlight
: 点击之后背景会变暗,同时不透明度会降低TouchableOpacity
: 点击之后会改变透明度TouchableNativeFeedback
: 点击之后会有水纹的效果(只支持android)
import {TouchableHighlight} from 'react-native'
<TouchableHighlight
onPress = {this.onPress}
onLongPress = {this.onLongPress}
onPressIn={this.onPressIn}
onPressOut={this.onPressOut}
disabled = {false}
activeOpacity={0.7}
underlayColor='black'
onHideUnderlay={this.onHideUnderlay}
onShowUnderlay={this.onShowUnderlay}
style={{ ... }}
>
</TouchableHighlight>
import {TouchableOpacity} from 'react-native'
<TouchableOpacity
onPress = {this.onPress}
onLongPress = {this.onLongPress}
onPressIn={this.onPressIn}
onPressOut={this.onPressOut}
disabled = {false}
activeOpacity={0.7}
style={{ ... }}
>
</TouchableOpacity>
import {TouchableNativeFeedback} from 'react-native'
<TouchableNativeFeedback
onPress = {this.onPress}
onLongPress = {this.onLongPress}
onPressIn={this.onPressIn}
onPressOut={this.onPressOut}
disabled = {false}
>
</TouchableNativeFeedback>