原生反应 MaskedView
提供使遮蔽视图的回放组件 .
支持的平台
- iOS系统
- 机器人
- 网页
开始
yarn add @react-native-masked-view/masked-view
或者说
npm install --save @react-native-masked-view/masked-view
使用本地反应 0.60
不需要手动连接软件包 自动链接。 。 。 .
记得安装起落架 :
npx pod-install
使用本地反应 < 0.60
然后,您需要将库的本地部分链接到你使用的平台。 链接库的最简单方式是使用 CLI 工具, 从您的工程根运行此命令 :
react-native link @react-native-masked-view/masked-view
使用量
导入 MaskedView 构成部分从 @react-native-masked-view/masked-view 像这样使用它:
import React from 'react';
import { Text, View } from 'react-native';
import MaskedView from '@react-native-masked-view/masked-view';
const App = () => {
return (
<MaskedView
style={{ flex: 1, flexDirection: 'row', height: '100%' }}
maskElement={
<View
style={{
// Transparent background because mask is based off alpha channel.
backgroundColor: 'transparent',
flex: 1,
justifyContent: 'center',
alignItems: 'center',
}}
>
<Text
style={{
fontSize: 60,
color: 'black',
fontWeight: 'bold',
}}
>
Basic Mask
</Text>
</View>
}
>
{/* Shows behind the mask, you can put anything here, such as an image */}
<View style={{ flex: 1, height: '100%', backgroundColor: '#324376' }} />
<View style={{ flex: 1, height: '100%', backgroundColor: '#F5DD90' }} />
<View style={{ flex: 1, height: '100%', backgroundColor: '#F76C5E' }} />
<View style={{ flex: 1, height: '100%', backgroundColor: '#e1e1e1' }} />
</MaskedView>
);
}
export default App
下面的图像表明,你几乎可以把任何东西放在面具后. 三个例子都被掩盖了 <View>, (中文(简体) ), <Text>,以及 <Image>。 。 。 .

道具
参考文献
maskElement
| 类型 | 需求 |
|---|---|
| 元素 | 对 |
androidRenderingMode
默认 hardware 渲染模式将被用于最佳性能,但如果您需要激活您的动能 maskElement 然后您需要切换到 software 让你的面具更新。 这个道具只影响Android.
| 类型 | 需求 | 默认 |
|---|---|---|
software, (中文(简体) ), hardware | 没有 | hardware |