MaskedViewIOS -- A way to apply alpha masks to views on iOS
Summary: It's very important in complex UIs to be able to apply alpha channel-based masks to arbitrary content. Common use cases include adding gradient masks at the top or bottom of scroll views, creating masked text effects, feathering images, and generally just masking views while still allowing transparency of those views. The original motivation for creating this component stemmed from work on `react-navigation`. As I tried to mimic behavior in the native iOS header, I needed to be able to achieve the effect pictured here (this is a screenshot from a native iOS application): ![iOS native navbar animation](https://slack-imgs.com/?c=1&url=https%3A%2F%2Fd3vv6lp55qjaqc.cloudfront.net%2Fitems%2F0N3g1Q3H423P3m1c1z3E%2FScreen%2520Shot%25202017-07-06%2520at%252011.57.29%2520AM.png) In this image, there are two masks: - A mask on the back button chevron - A gradient mask on the right button In addition, the underlying view in the navigation bar is intended to be a UIBlurView. Thus, alpha masking is the only way to achieve this effect. Behind the scenes, the `maskView` property on `UIView` is used. This is a shortcut to setting the mask on the CALayer directly. This gives us the ability to mask any view with any other view. While building this component (and testing in the context of an Expo app), I was able to use a `GLView` (a view that renders an OpenGL context) to mask a `Video` component! I chose to implement this only on iOS right now, as the Android implementation is a) significantly more complicated and b) will most likely not be as performant (especially when trying to mask more complex views). Review the `<MaskedViewIOS>` section in the RNTester app, observe that views are masked appropriately. ![example](https://d3vv6lp55qjaqc.cloudfront.net/items/250X092v2k3f212f3O16/Screen%20Recording%202017-07-07%20at%2012.18%20PM.gif?X-CloudApp-Visitor-Id=abb33b3e3769bbe2f7b26d13dc5d1442&v=5f9e2d4c) Closes https://github.com/facebook/react-native/pull/14898 Differential Revision: D5398721 Pulled By: javache fbshipit-source-id: 343af874e2d664541aca1fefe922cf7d82aea701
This commit is contained in:
parent
0c44b9e9b0
commit
8ea6cea39a
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule MaskedViewIOS
|
||||
* @flow
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
module.exports = require('UnimplementedView');
|
|
@ -0,0 +1,110 @@
|
|||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule MaskedViewIOS
|
||||
* @flow
|
||||
*/
|
||||
|
||||
const React = require('React');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const View = require('View');
|
||||
const ViewPropTypes = require('ViewPropTypes');
|
||||
const requireNativeComponent = require('requireNativeComponent');
|
||||
const ReactPropTypes = React.PropTypes;
|
||||
|
||||
import type { ViewProps } from 'ViewPropTypes';
|
||||
|
||||
type Props = ViewProps & {
|
||||
children: any,
|
||||
/**
|
||||
* Should be a React element to be rendered and applied as the
|
||||
* mask for the child element.
|
||||
*/
|
||||
maskElement: React.Element<*>,
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders the child view with a mask specified in the `maskElement` prop.
|
||||
*
|
||||
* ```
|
||||
* import React from 'react';
|
||||
* import { MaskedView, Text, View } from 'react-native';
|
||||
*
|
||||
* class MyMaskedView extends React.Component {
|
||||
* render() {
|
||||
* return (
|
||||
* <MaskedView
|
||||
* style={{ flex: 1 }}
|
||||
* maskElement={
|
||||
* <View style={styles.maskContainerStyle}>
|
||||
* <Text style={styles.maskTextStyle}>
|
||||
* Basic Mask
|
||||
* </Text>
|
||||
* </View>
|
||||
* }
|
||||
* >
|
||||
* <View style={{ flex: 1, backgroundColor: 'blue' }} />
|
||||
* </MaskedView>
|
||||
* );
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* The above example will render a view with a blue background that fills its
|
||||
* parent, and then mask that view with text that says "Basic Mask".
|
||||
*
|
||||
* The alpha channel of the view rendered by the `maskElement` prop determines how
|
||||
* much of the view's content and background shows through. Fully or partially
|
||||
* opaque pixels allow the underlying content to show through but fully
|
||||
* transparent pixels block that content.
|
||||
*
|
||||
*/
|
||||
class MaskedViewIOS extends React.Component {
|
||||
props: Props;
|
||||
|
||||
static propTypes = {
|
||||
...ViewPropTypes,
|
||||
maskElement: ReactPropTypes.element.isRequired,
|
||||
};
|
||||
|
||||
_hasWarnedInvalidRenderMask = false;
|
||||
|
||||
render() {
|
||||
const { maskElement, children, ...otherViewProps } = this.props;
|
||||
|
||||
if (!React.isValidElement(maskElement)) {
|
||||
if (!this._hasWarnedInvalidRenderMask) {
|
||||
console.warn(
|
||||
'MaskedView: Invalid `maskElement` prop was passed to MaskedView. ' +
|
||||
'Expected a React Element. No mask will render.'
|
||||
);
|
||||
this._hasWarnedInvalidRenderMask = true;
|
||||
}
|
||||
return <View {...otherViewProps}>{children}</View>;
|
||||
}
|
||||
|
||||
return (
|
||||
<RCTMaskedView {...otherViewProps}>
|
||||
<View pointerEvents="none" style={StyleSheet.absoluteFill}>
|
||||
{maskElement}
|
||||
</View>
|
||||
{children}
|
||||
</RCTMaskedView>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const RCTMaskedView = requireNativeComponent('RCTMaskedView', {
|
||||
name: 'RCTMaskedView',
|
||||
displayName: 'RCTMaskedView',
|
||||
propTypes: {
|
||||
...ViewPropTypes,
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = MaskedViewIOS;
|
|
@ -29,6 +29,7 @@ const ReactNative = {
|
|||
get ImageStore() { return require('ImageStore'); },
|
||||
get KeyboardAvoidingView() { return require('KeyboardAvoidingView'); },
|
||||
get ListView() { return require('ListView'); },
|
||||
get MaskedViewIOS() { return require('MaskedViewIOS'); },
|
||||
get Modal() { return require('Modal'); },
|
||||
get NavigatorIOS() { return require('NavigatorIOS'); },
|
||||
get Picker() { return require('Picker'); },
|
||||
|
|
|
@ -0,0 +1,196 @@
|
|||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @flow
|
||||
* @providesModule MaskedViewExample
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const RNTesterBlock = require('RNTesterBlock');
|
||||
const RNTesterPage = require('RNTesterPage');
|
||||
const {
|
||||
Animated,
|
||||
Image,
|
||||
MaskedViewIOS,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
} = require('react-native');
|
||||
|
||||
class MaskedViewExample extends React.Component {
|
||||
static title = '<MaskedViewIOS>';
|
||||
static description = 'Renders the child view with a mask specified in the `renderMask` prop.';
|
||||
|
||||
state = {
|
||||
alternateChildren: true,
|
||||
};
|
||||
|
||||
_maskRotateAnimatedValue = new Animated.Value(0);
|
||||
_maskScaleAnimatedValue = new Animated.Value(1);
|
||||
|
||||
componentDidMount() {
|
||||
setInterval(() => {
|
||||
this.setState(state => ({
|
||||
alternateChildren: !state.alternateChildren,
|
||||
}));
|
||||
}, 1000);
|
||||
|
||||
Animated.loop(
|
||||
Animated.sequence([
|
||||
Animated.timing(this._maskScaleAnimatedValue, {
|
||||
toValue: 1.3,
|
||||
timing: 750,
|
||||
useNativeDriver: true,
|
||||
}),
|
||||
Animated.timing(this._maskScaleAnimatedValue, {
|
||||
toValue: 1,
|
||||
timing: 750,
|
||||
useNativeDriver: true,
|
||||
}),
|
||||
])
|
||||
).start();
|
||||
|
||||
Animated.loop(
|
||||
Animated.timing(this._maskRotateAnimatedValue, {
|
||||
toValue: 360,
|
||||
timing: 2000,
|
||||
useNativeDriver: true,
|
||||
})
|
||||
).start();
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<RNTesterPage title="<MaskedViewIOS>">
|
||||
<RNTesterBlock title="Basic Mask">
|
||||
<View style={{ width: 300, height: 300, alignSelf: 'center' }}>
|
||||
<MaskedViewIOS
|
||||
style={{ flex: 1 }}
|
||||
maskElement={
|
||||
<View style={styles.maskContainerStyle}>
|
||||
<Text style={styles.maskTextStyle}>
|
||||
Basic Mask
|
||||
</Text>
|
||||
</View>
|
||||
}>
|
||||
<View style={{ flex: 1, backgroundColor: 'blue' }} />
|
||||
<View style={{ flex: 1, backgroundColor: 'red' }} />
|
||||
</MaskedViewIOS>
|
||||
</View>
|
||||
</RNTesterBlock>
|
||||
<RNTesterBlock title="Image Mask">
|
||||
<View
|
||||
style={{
|
||||
width: 300,
|
||||
height: 300,
|
||||
alignSelf: 'center',
|
||||
backgroundColor: '#eeeeee',
|
||||
}}>
|
||||
<MaskedViewIOS
|
||||
style={{ flex: 1 }}
|
||||
maskElement={
|
||||
<View style={styles.maskContainerStyle}>
|
||||
<Image
|
||||
style={{ height: 200, width: 200 }}
|
||||
source={require('./imageMask.png')}
|
||||
/>
|
||||
</View>
|
||||
}>
|
||||
<View style={styles.maskContainerStyle}>
|
||||
<Image
|
||||
resizeMode="cover"
|
||||
style={{ width: 200, height: 200 }}
|
||||
source={{
|
||||
uri:
|
||||
'https://38.media.tumblr.com/9e9bd08c6e2d10561dd1fb4197df4c4e/tumblr_mfqekpMktw1rn90umo1_500.gif',
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
</MaskedViewIOS>
|
||||
</View>
|
||||
</RNTesterBlock>
|
||||
<RNTesterBlock title="Animated Mask">
|
||||
<View style={{ width: 300, height: 300, alignSelf: 'center' }}>
|
||||
<MaskedViewIOS
|
||||
style={{ flex: 1 }}
|
||||
maskElement={
|
||||
<Animated.View
|
||||
style={[
|
||||
styles.maskContainerStyle,
|
||||
{ transform: [{ scale: this._maskScaleAnimatedValue }] },
|
||||
]}>
|
||||
<Text style={styles.maskTextStyle}>
|
||||
Basic Mask
|
||||
</Text>
|
||||
</Animated.View>
|
||||
}>
|
||||
<Animated.View
|
||||
style={{
|
||||
flex: 1,
|
||||
transform: [
|
||||
{
|
||||
rotate: this._maskRotateAnimatedValue.interpolate({
|
||||
inputRange: [0, 360],
|
||||
outputRange: ['0deg', '360deg'],
|
||||
}),
|
||||
},
|
||||
],
|
||||
}}>
|
||||
<View style={{ flex: 1, backgroundColor: 'blue' }} />
|
||||
<View style={{ flex: 1, backgroundColor: 'red' }} />
|
||||
</Animated.View>
|
||||
</MaskedViewIOS>
|
||||
</View>
|
||||
</RNTesterBlock>
|
||||
<RNTesterBlock title="Mask w/ Changing Children">
|
||||
<View style={{ width: 300, height: 300, alignSelf: 'center' }}>
|
||||
<MaskedViewIOS
|
||||
style={{ flex: 1 }}
|
||||
maskElement={
|
||||
<View style={styles.maskContainerStyle}>
|
||||
<Text style={styles.maskTextStyle}>
|
||||
Basic Mask
|
||||
</Text>
|
||||
</View>
|
||||
}>
|
||||
{this.state.alternateChildren
|
||||
? [
|
||||
<View
|
||||
key={1}
|
||||
style={{ flex: 1, backgroundColor: 'blue' }}
|
||||
/>,
|
||||
<View
|
||||
key={2}
|
||||
style={{ flex: 1, backgroundColor: 'red' }}
|
||||
/>,
|
||||
]
|
||||
: null}
|
||||
</MaskedViewIOS>
|
||||
</View>
|
||||
</RNTesterBlock>
|
||||
</RNTesterPage>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
maskContainerStyle: {
|
||||
flex: 1,
|
||||
backgroundColor: 'transparent',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
},
|
||||
maskTextStyle: {
|
||||
backgroundColor: 'transparent',
|
||||
fontSize: 40,
|
||||
fontWeight: 'bold',
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = MaskedViewExample;
|
|
@ -73,6 +73,11 @@ const ComponentExamples: Array<RNTesterExample> = [
|
|||
module: require('./ListViewPagingExample'),
|
||||
supportsTVOS: true,
|
||||
},
|
||||
{
|
||||
key: 'MaskedViewExample',
|
||||
module: require('./MaskedViewExample'),
|
||||
supportsTVOS: true,
|
||||
},
|
||||
{
|
||||
key: 'ModalExample',
|
||||
module: require('./ModalExample'),
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
|
@ -1047,6 +1047,14 @@
|
|||
657734931EE8356100A0E9EA /* RCTInspector.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6577348B1EE8354A00A0E9EA /* RCTInspector.mm */; };
|
||||
657734941EE8356100A0E9EA /* RCTInspectorPackagerConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 6577348C1EE8354A00A0E9EA /* RCTInspectorPackagerConnection.h */; };
|
||||
657734951EE8356100A0E9EA /* RCTInspectorPackagerConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 6577348D1EE8354A00A0E9EA /* RCTInspectorPackagerConnection.m */; };
|
||||
66CD94B11F1045E700CB3C7C /* RCTMaskedView.h in Headers */ = {isa = PBXBuildFile; fileRef = 66CD94AD1F1045E700CB3C7C /* RCTMaskedView.h */; };
|
||||
66CD94B21F1045E700CB3C7C /* RCTMaskedView.h in Headers */ = {isa = PBXBuildFile; fileRef = 66CD94AD1F1045E700CB3C7C /* RCTMaskedView.h */; };
|
||||
66CD94B31F1045E700CB3C7C /* RCTMaskedView.m in Sources */ = {isa = PBXBuildFile; fileRef = 66CD94AE1F1045E700CB3C7C /* RCTMaskedView.m */; };
|
||||
66CD94B41F1045E700CB3C7C /* RCTMaskedView.m in Sources */ = {isa = PBXBuildFile; fileRef = 66CD94AE1F1045E700CB3C7C /* RCTMaskedView.m */; };
|
||||
66CD94B51F1045E700CB3C7C /* RCTMaskedViewManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 66CD94AF1F1045E700CB3C7C /* RCTMaskedViewManager.h */; };
|
||||
66CD94B61F1045E700CB3C7C /* RCTMaskedViewManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 66CD94AF1F1045E700CB3C7C /* RCTMaskedViewManager.h */; };
|
||||
66CD94B71F1045E700CB3C7C /* RCTMaskedViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 66CD94B01F1045E700CB3C7C /* RCTMaskedViewManager.m */; };
|
||||
66CD94B81F1045E700CB3C7C /* RCTMaskedViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 66CD94B01F1045E700CB3C7C /* RCTMaskedViewManager.m */; };
|
||||
68EFE4EE1CF6EB3900A1DE13 /* RCTBundleURLProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 68EFE4ED1CF6EB3900A1DE13 /* RCTBundleURLProvider.m */; };
|
||||
830A229E1A66C68A008503DA /* RCTRootView.m in Sources */ = {isa = PBXBuildFile; fileRef = 830A229D1A66C68A008503DA /* RCTRootView.m */; };
|
||||
83392EB31B6634E10013B15F /* RCTModalHostViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83392EB21B6634E10013B15F /* RCTModalHostViewController.m */; };
|
||||
|
@ -1957,6 +1965,10 @@
|
|||
6577348B1EE8354A00A0E9EA /* RCTInspector.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RCTInspector.mm; path = Inspector/RCTInspector.mm; sourceTree = "<group>"; };
|
||||
6577348C1EE8354A00A0E9EA /* RCTInspectorPackagerConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RCTInspectorPackagerConnection.h; path = Inspector/RCTInspectorPackagerConnection.h; sourceTree = "<group>"; };
|
||||
6577348D1EE8354A00A0E9EA /* RCTInspectorPackagerConnection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RCTInspectorPackagerConnection.m; path = Inspector/RCTInspectorPackagerConnection.m; sourceTree = "<group>"; };
|
||||
66CD94AD1F1045E700CB3C7C /* RCTMaskedView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTMaskedView.h; sourceTree = "<group>"; };
|
||||
66CD94AE1F1045E700CB3C7C /* RCTMaskedView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTMaskedView.m; sourceTree = "<group>"; };
|
||||
66CD94AF1F1045E700CB3C7C /* RCTMaskedViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTMaskedViewManager.h; sourceTree = "<group>"; };
|
||||
66CD94B01F1045E700CB3C7C /* RCTMaskedViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTMaskedViewManager.m; sourceTree = "<group>"; };
|
||||
68EFE4EC1CF6EB3000A1DE13 /* RCTBundleURLProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTBundleURLProvider.h; sourceTree = "<group>"; };
|
||||
68EFE4ED1CF6EB3900A1DE13 /* RCTBundleURLProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTBundleURLProvider.m; sourceTree = "<group>"; };
|
||||
6A15FB0C1BDF663500531DFB /* RCTRootViewInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTRootViewInternal.h; sourceTree = "<group>"; };
|
||||
|
@ -2252,6 +2264,10 @@
|
|||
58C571BF1AA56C1900CDF9C8 /* RCTDatePickerManager.m */,
|
||||
3D37B5801D522B190042D5B5 /* RCTFont.h */,
|
||||
3D37B5811D522B190042D5B5 /* RCTFont.mm */,
|
||||
66CD94AD1F1045E700CB3C7C /* RCTMaskedView.h */,
|
||||
66CD94AE1F1045E700CB3C7C /* RCTMaskedView.m */,
|
||||
66CD94AF1F1045E700CB3C7C /* RCTMaskedViewManager.h */,
|
||||
66CD94B01F1045E700CB3C7C /* RCTMaskedViewManager.m */,
|
||||
83A1FE8A1B62640A00BE0E65 /* RCTModalHostView.h */,
|
||||
83A1FE8B1B62640A00BE0E65 /* RCTModalHostView.m */,
|
||||
83392EB11B6634E10013B15F /* RCTModalHostViewController.h */,
|
||||
|
@ -2699,6 +2715,7 @@
|
|||
590D7BFE1EBD458B00D8A370 /* RCTShadowView+Layout.h in Headers */,
|
||||
13134C9D1E296B2A00B9F3CB /* RCTCxxModule.h in Headers */,
|
||||
59FBEFB11E46D91C0095D885 /* RCTScrollContentShadowView.h in Headers */,
|
||||
66CD94B61F1045E700CB3C7C /* RCTMaskedViewManager.h in Headers */,
|
||||
130443A31E3FEAAE00D93A67 /* RCTFollyConvert.h in Headers */,
|
||||
3D7BFD1E1EA8E351008DFB7A /* RCTPackagerConnection.h in Headers */,
|
||||
59FBEFB51E46D91C0095D885 /* RCTScrollContentViewManager.h in Headers */,
|
||||
|
@ -2816,6 +2833,7 @@
|
|||
CF2731C21E7B8DEF0044CA4F /* RCTDeviceInfo.h in Headers */,
|
||||
3D302F8B1DF828F800D6DDAE /* RCTScrollViewManager.h in Headers */,
|
||||
3D302F8C1DF828F800D6DDAE /* RCTSegmentedControl.h in Headers */,
|
||||
66CD94B21F1045E700CB3C7C /* RCTMaskedView.h in Headers */,
|
||||
3D302F8D1DF828F800D6DDAE /* RCTSegmentedControlManager.h in Headers */,
|
||||
3D302F8E1DF828F800D6DDAE /* RCTShadowView.h in Headers */,
|
||||
3D302F8F1DF828F800D6DDAE /* RCTSlider.h in Headers */,
|
||||
|
@ -3075,6 +3093,7 @@
|
|||
3D80DA661DF820620028D040 /* RCTComponentData.h in Headers */,
|
||||
3DA9819E1E5B0DBB004F2374 /* NSDataBigString.h in Headers */,
|
||||
3D80DA671DF820620028D040 /* RCTConvert+CoreLocation.h in Headers */,
|
||||
66CD94B11F1045E700CB3C7C /* RCTMaskedView.h in Headers */,
|
||||
3D80DA691DF820620028D040 /* RCTDatePicker.h in Headers */,
|
||||
3D80DA6A1DF820620028D040 /* RCTDatePickerManager.h in Headers */,
|
||||
3D80DA6B1DF820620028D040 /* RCTFont.h in Headers */,
|
||||
|
@ -3110,6 +3129,7 @@
|
|||
3D80DA881DF820620028D040 /* RCTTabBar.h in Headers */,
|
||||
3D80DA891DF820620028D040 /* RCTTabBarItem.h in Headers */,
|
||||
3D80DA8A1DF820620028D040 /* RCTTabBarItemManager.h in Headers */,
|
||||
66CD94B51F1045E700CB3C7C /* RCTMaskedViewManager.h in Headers */,
|
||||
3D80DA8B1DF820620028D040 /* RCTTabBarManager.h in Headers */,
|
||||
3D80DA8C1DF820620028D040 /* RCTTextDecorationLineType.h in Headers */,
|
||||
6577348E1EE8354A00A0E9EA /* RCTInspector.h in Headers */,
|
||||
|
@ -3551,6 +3571,7 @@
|
|||
2DD0EFE11DA84F2800B0C975 /* RCTStatusBarManager.m in Sources */,
|
||||
2D3B5EC91D9B095C00451313 /* RCTBorderDrawing.m in Sources */,
|
||||
C6194AAF1EF156280034D062 /* RCTPackagerConnectionBridgeConfig.m in Sources */,
|
||||
66CD94B81F1045E700CB3C7C /* RCTMaskedViewManager.m in Sources */,
|
||||
2D3B5E991D9B089A00451313 /* RCTDisplayLink.m in Sources */,
|
||||
2D3B5EA11D9B08B600451313 /* RCTModuleData.mm in Sources */,
|
||||
2D3B5EEA1D9B09CD00451313 /* RCTTabBar.m in Sources */,
|
||||
|
@ -3637,6 +3658,7 @@
|
|||
657734861EE834D900A0E9EA /* RCTInspectorDevServerHelper.mm in Sources */,
|
||||
59FBEFB31E46D91C0095D885 /* RCTScrollContentShadowView.m in Sources */,
|
||||
2D3B5ED91D9B098E00451313 /* RCTNavItem.m in Sources */,
|
||||
66CD94B41F1045E700CB3C7C /* RCTMaskedView.m in Sources */,
|
||||
2D74EAFA1DAE9590003B751B /* RCTMultipartDataTask.m in Sources */,
|
||||
2D3B5EC51D9B094D00451313 /* RCTProfileTrampoline-i386.S in Sources */,
|
||||
657734951EE8356100A0E9EA /* RCTInspectorPackagerConnection.m in Sources */,
|
||||
|
@ -3806,6 +3828,7 @@
|
|||
13B07FEF1A69327A00A75B9A /* RCTAlertManager.m in Sources */,
|
||||
3D7BFD231EA8E351008DFB7A /* RCTReloadPackagerMethod.m in Sources */,
|
||||
352DCFF01D19F4C20056D623 /* RCTI18nUtil.m in Sources */,
|
||||
66CD94B71F1045E700CB3C7C /* RCTMaskedViewManager.m in Sources */,
|
||||
008341F61D1DB34400876D9A /* RCTJSStackFrame.m in Sources */,
|
||||
13134C961E296B2A00B9F3CB /* RCTObjcExecutor.mm in Sources */,
|
||||
83CBBACC1A6023D300E9B192 /* RCTConvert.m in Sources */,
|
||||
|
@ -3885,6 +3908,7 @@
|
|||
13C156051AB1A2840079392D /* RCTWebView.m in Sources */,
|
||||
83CBBA601A601EAA00E9B192 /* RCTBridge.m in Sources */,
|
||||
590D7BFF1EBD458B00D8A370 /* RCTShadowView+Layout.m in Sources */,
|
||||
66CD94B31F1045E700CB3C7C /* RCTMaskedView.m in Sources */,
|
||||
13C156061AB1A2840079392D /* RCTWebViewManager.m in Sources */,
|
||||
C6194AAE1EF156280034D062 /* RCTPackagerConnectionBridgeConfig.m in Sources */,
|
||||
58114A161AAE854800E7D092 /* RCTPicker.m in Sources */,
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import <React/RCTView.h>
|
||||
|
||||
@interface RCTMaskedView : RCTView
|
||||
|
||||
@end
|
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#import "RCTMaskedView.h"
|
||||
|
||||
#import <React/UIView+React.h>
|
||||
|
||||
@implementation RCTMaskedView
|
||||
|
||||
- (void)didUpdateReactSubviews
|
||||
{
|
||||
// RCTMaskedView expects that the first subview rendered is the mask.
|
||||
UIView *maskView = [self.reactSubviews firstObject];
|
||||
self.maskView = maskView;
|
||||
|
||||
// Add the other subviews to the view hierarchy
|
||||
for (NSUInteger i = 1; i < self.reactSubviews.count; i++) {
|
||||
UIView *subview = [self.reactSubviews objectAtIndex:i];
|
||||
[self addSubview:subview];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)displayLayer:(CALayer *)layer
|
||||
{
|
||||
// RCTView uses displayLayer to do border rendering.
|
||||
// We don't need to do that in RCTMaskedView, so we
|
||||
// stub this method and override the default implementation.
|
||||
}
|
||||
|
||||
@end
|
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#import <React/RCTViewManager.h>
|
||||
|
||||
@interface RCTMaskedViewManager : RCTViewManager
|
||||
|
||||
@end
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#import "RCTMaskedViewManager.h"
|
||||
|
||||
#import "RCTMaskedView.h"
|
||||
#import "RCTUIManager.h"
|
||||
|
||||
@implementation RCTMaskedViewManager
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
- (UIView *)view
|
||||
{
|
||||
return [RCTMaskedView new];
|
||||
}
|
||||
|
||||
@end
|
|
@ -18,6 +18,7 @@ const components = [
|
|||
'../Libraries/Image/Image.ios.js',
|
||||
'../Libraries/Components/Keyboard/KeyboardAvoidingView.js',
|
||||
'../Libraries/Lists/ListView/ListView.js',
|
||||
'../Libraries/Components/MaskedView/MaskedViewIOS.ios.js',
|
||||
'../Libraries/Modal/Modal.js',
|
||||
'../Libraries/Components/Navigation/NavigatorIOS.ios.js',
|
||||
'../Libraries/Components/Picker/Picker.js',
|
||||
|
|
Loading…
Reference in New Issue