【发布时间】:2018-06-30 12:46:26
【问题描述】:
在移动应用中,显示用户已触摸特定元素的某种指示至关重要,尤其是在尝试触摸将重定向的元素时。因此,我希望在触摸时更改 touchableOpacity 元素的背景颜色,然后恢复为原始背景颜色。
例如,如果用户触摸了这个元素:
触摸时背景颜色会改变。
如何在touchableOpacity 中执行此操作?
<TouchableOpacity
style={[styles.verticalCenter, styles.floatRight]}
activeOpacity={1.0}
underlayColor="rgba(253,138,94,0)"
onPress={()=> this.openModal()}
>
<Ionicons name="log-out" size={16} color="#bccad0" />
</TouchableOpacity>
floatRight: {
flex: 1,
alignItems: 'center',
borderWidth: 1,
borderColor: 'rgba(0,0,0,0.2)',
justifyContent: 'center',
width: 30,
height: 30,
backgroundColor: '#fff',
borderRadius: 100 / 2,
},
以上方法都行不通。
任何帮助将不胜感激。
【问题讨论】:
标签: javascript android reactjs react-native touchableopacity