React Native

React native 키보드 내리기

Machine_웅 2020. 1. 16. 17:20
728x90
반응형
export  default  class App extends Component {

  // 키보드를 화면에서 사라지게 함(
  dismissKeyboard () {
    Keyboard.dismiss()
  }
 
  render () {
    return (
      <View style={styles.container}>
        <TextInput style={styles.input} />
        {/* UI의 버튼에 dismissKeyboard 메서드를 연결 */}
        <TouchableHighlight
          onPress={this.dismissKeyboard}
          style={styles.button}>
          <Text>Dismiss Keyboard</Text>
        </TouchableHighlight>
      </View>
    )
  }
}

styles = StyleSheet.create({
  container: {
    flex: 1,
    marginTop: 150,
  },
  input: {
    margin: 10,
    backgroundColor: '#ededed',
    height: 50,
    padding: 10
  },
  button: {
    height: 50,
    backgroundColor: '#dddddd',
    margin: 10,
    justifyContent: 'center',
    alignItems: 'center'
  }
})
728x90
반응형