TouchableHighlight underlayColor 不起作用。颜色只是没有改变
TouchableHighlight underlayColor not working. The color just does not change
我有一个组件:
<TouchableHighlight
style={styles.button}
underlayColor='red'
onPress={() => this.bootEvent(item)}>
<Text style={{ color: '#ffffff', fontSize: 12, fontWeight: 'bold' }}>Text</Text>
</TouchableHighlight>
这是风格:
button: {
alignItems: 'center',
backgroundColor: '#4267b2',
padding: 8
}
问题是当我点击按钮时,onPress 函数被调用,但 TouchableHighlight 的颜色保持不变。
我也试过这个:
underlayColor={'red'}
有括号,但是一样
如果有人遇到这种情况,需要提供 onPress
才能看到颜色变化或突出显示效果。参见 https://github.com/facebook/react-native/issues/14908
我有一个组件:
<TouchableHighlight
style={styles.button}
underlayColor='red'
onPress={() => this.bootEvent(item)}>
<Text style={{ color: '#ffffff', fontSize: 12, fontWeight: 'bold' }}>Text</Text>
</TouchableHighlight>
这是风格:
button: {
alignItems: 'center',
backgroundColor: '#4267b2',
padding: 8
}
问题是当我点击按钮时,onPress 函数被调用,但 TouchableHighlight 的颜色保持不变。
我也试过这个:
underlayColor={'red'}
有括号,但是一样
如果有人遇到这种情况,需要提供 onPress
才能看到颜色变化或突出显示效果。参见 https://github.com/facebook/react-native/issues/14908