React Native组件按键时隐藏或显示视图的方法

764 阅读1分钟

Hide Or Show View On Keypress

一个最小的React Native组件,当键盘出现时显示或隐藏一个视图。

如何使用它

1.安装并导入。

# Yarn
$ yarn add react-native-hide-onkeyboard

# NPM
$ npm i react-native-hide-onkeyboard
import { HideOnKeyboard, ShowOnKeyboard } from "react-native-hide-onkeyboard";

2.使用方法。

<ShowOnKeyboard>
  <Text> I will only appear when the keyboard is open</Text>
</ShowOnKeyboard>
<HideOnKeyboard style={{ backgroundColor: 'red', height: 100, width: 100 }}>
  <Text >I will hide when the key board is open</Text>
</HideOnKeyboard>

预览

Hide Or Show View On Keypress

The postHide Or Show View On Keypressappeared first onReactScript.