@react-native-community/masked-view
React Native MaskedView component
Last updated 5 months ago by mike.nedosekin .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @react-native-community/masked-view 
SYNC missed versions from official npm registry.

React Native MaskedView

Build Status Version MIT License Lean Core Badge

React Native MaskedView for iOS and Android.

Platforms Supported

  • [x] iOS
  • [x] Android

Note: React Native MaskedView is not currently supported by Expo unless you "eject".

Getting Started

$ yarn add @react-native-community/masked-view

or

$ npm install --save @react-native-community/masked-view

Using React Native >= 0.60

Linking the package manually is not required anymore with Autolinking.

  • iOS Platform:

    $ cd ios && pod install

Using React Native < 0.60

You then need to link the native parts of the library for the platforms you are using. The easiest way to link the library is using the CLI tool by running this command from the root of your project:

$ react-native link @react-native-community/masked-view

Usage

Import the MaskedView component from @react-native-community/masked-view and use it like so:

import React from 'react';
import { Text, View } from 'react-native';
import MaskedView from '@react-native-community/masked-view';

export default class App extends React.Component {
  render() {
    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>
    );
  }
}

The following image demonstrates that you can put almost anything behind the mask. The three examples shown are masked <View>, <Text>, and <Image>.

Props

Reference

Props

maskElement

Type Required
element Yes

Current Tags

  • 0.1.10                                ...           latest (5 months ago)

16 Versions

  • 0.1.10                                ...           5 months ago
  • 0.1.9                                ...           5 months ago
  • 0.1.8                                ...           5 months ago
  • 0.1.7                                ...           7 months ago
  • 0.1.6                                ...           8 months ago
  • 0.1.5                                ...           a year ago
  • 0.1.4                                ...           a year ago
  • 0.1.3                                ...           a year ago
  • 0.1.2                                ...           a year ago
  • 0.1.1                                ...           a year ago
  • 0.1.0                                ...           a year ago
  • 0.0.5                                ...           a year ago
  • 0.0.4                                ...           a year ago
  • 0.0.3                                ...           a year ago
  • 0.0.2                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Maintainers (1)
Downloads
Today 117
This Week 1,342
This Month 5,662
Last Day 249
Last Week 1,494
Last Month 6,873
Dependencies (0)
None
Dev Dependencies (7)
Dependents (177)

Copyright 2014 - 2016 © taobao.org |