@amazon-devices/react-native-masked-view__masked-view

中文文档
2.0.9000000003发布于 2026/10/30See license in LICENSETypeScriptCommonJS零依赖近 30 天下载 3828

反应原生 MaskedView 组件

中文使用文档
文档目录9 节
  1. 支持的平台
  2. 开始
  3. 使用本地反应 0.60
  4. 使用本地反应 < 0.60
  5. 使用量
  6. 道具
  7. 参考文献
  8. maskElement
  9. androidRenderingMode

原生反应 MaskedView

Build Status Version MIT License Lean Core Badge

提供使遮蔽视图的回放组件 .

支持的平台

  • 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

版本与发布记录

@amazon-devices/react-native-masked-view__masked-view 共发布 7 个版本,首次发布于 2025/09/25;过去 12 个月发布了 5 个版本。

版本发布日期距今
2.0.9000000003latest2026/10/309 天前
2.0.90000000022026/08/073 个月前
2.0.9000000002-rn-83rn83-alpha2026/06/244 个月前
2.0.90000000002026/06/184 个月前
2.0.9000000000-rn-832026/06/134 个月前
2.0.17591359702025/09/301.1 年前

关于 @amazon-devices/react-native-masked-view__masked-view 的常见问题

@amazon-devices/react-native-masked-view__masked-view 是什么?

反应原生 MaskedView 组件

如何安装 @amazon-devices/react-native-masked-view__masked-view?

在项目目录运行 npm install @amazon-devices/react-native-masked-view__masked-view,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(*)、react-native(*)、@amazon-devices/react-native-kepler(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@amazon-devices/react-native-masked-view__masked-view 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@amazon-devices/react-native-masked-view__masked-view 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@amazon-devices/react-native-masked-view__masked-view 可以商用吗?

@amazon-devices/react-native-masked-view__masked-view 使用 See license in LICENSE 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@amazon-devices/react-native-masked-view__masked-view 的下载量有多少?

根据 npm 官方下载统计,@amazon-devices/react-native-masked-view__masked-view 在 2026/10/06 – 2026/11/04 这 30 天内被下载 3,828 次,日均约 128 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@amazon-devices/react-native-masked-view__masked-view 还在维护吗?

最新版本 2.0.9000000003 发布于 2026/10/30(9 天前);至今共发布 7 个版本,其中过去 12 个月发布了 5 个;首次发布于 2025/09/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。