当文本输入字段聚焦时,如何更改边框颜色或如何在文本输入字段中添加或更改样式以响应 native 。
(对于android)
最佳答案
您可以使用 onFocus
和 onBlur
来完成这项工作
state: {
isFocused: true
}
handleFocus = () => this.setState({isFocused: true})
handleBlur = () => this.setState({isFocused: false})
<TextInput
onFocus={this.handleFocus}
onBlur={this.handleBlur}
style={[//Your Styles, {
borderBottomColor: this.state.isFocused
? 'black'
: 'red',
borderBottomWidth: 1,
}]}
/>
关于react-native - 如何在React Native应用程序中更改文本输入的边框颜色,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50168669/