I’m trying to reproduce the following layout in React Native/Expo, I found the @react-native-masked-view/masked-view
that seemed, at first glance, to cover my needs.
I need to have a map (I’m using react-native-maps) and cover part of it with some blurry semi-transparent white view.
But I realized it doesn’t properly support semi-transparent masks, because if I use them, any content I put on top of the blur area inherits the mask transparency as well, even if positioned outside the MAskedView component.
Also, it doesn’t seem to support blurring the content behind the mask.
How can I reproduce this on React Native?
Below you can see a mockup to understand what I’m trying to achieve.
2
Answers
What you ask is not easy. Anyway I found a way which gets close to it:
This renders a map which is blurred in the upper half and clear in the lower half. Maybe if you play a little with styles, you can obtain what you want!
Unfortunately, the
@react-native-masked-view/masked-view
library does not support blurring the content behind the mask, nor does it handle semi-transparent masks well.However, there are some other libraries such as
@react-native-community/blur
that you can try to use instead.You can install it with:
Then you can try this: