Source: https://github.com/amlcurran/ShowcaseView
By checking source code, it has some png
.
Setting a backgroundColor rgba(0, 0, 0, 0.8)
and creating a circle view on top of this simply doesn't work.
How do I create an Overlay like this in react-native?
Use rgba value for the backgroundColor . This sets it to a grey color with 80% opacity, which is derived from the opacity decimal, 0.8 . This value can be anything from 0.0 to 1.0 .
To create CSS circles in React Native, we can set the borderRadius style to '50%' . to set the width and height of the View . Then we set borderRadius to '50%' to make it a circle.
Specify Opacity of a Color in React If you want to specify the opacity of background color, you should use the rgba() , which is slightly different from rgb() function. The decimal value can be anything from 0 to 1 . In this case, our background will be 30% colored and 70% transparent .
yes can use react-native-svg for this purpose.
you can get your solution from my code. i hope this will 100% work for you.
import { Svg, Defs, Rect, Mask, Circle } from 'react-native-svg';
const WrappedSvg = () => (
<View style={{ aspectRatio: 1 }}>
<Svg height="100%" width="100%" viewBox="0 0 100 100">
<Defs>
<Mask id="mask" x="0" y="0" height="100%" width="100%">
<Rect height="100%" width="100%" fill="#fff" />
<Circle r="45" cx="50" cy="50" />
</Mask>
</Defs>
<Rect height="100%" width="100%" fill="rgba(0, 0, 0, 0.5)" mask="url(#mask)" fill-opacity="0" />
</Svg>
</View>
);
export class index extends Component {
render() {
return (
<View style={{ backgroundColor: '#FFFFFF', flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<View style={{ width: Dimensions.get('window').width, height: 300, position: 'absolute' }}>
<WrappedSvg />
</View>
</View>
);
}
}
export default index;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With