Hi I want to draw like below curve triangle with use View or something but white area must be a transparent it should only look red how can I do that thanks for suggestions
Asked
Active
Viewed 505 times
0
-
checkout here may be this will help [you](https://codedaily.io/tutorials/The-Shapes-of-React-Native) – Kiran Mistry May 07 '21 at 12:45
-
Thanks, I saw but it is not suitable for me – Alisan26 May 07 '21 at 12:49
2 Answers
1
The best way to achieve this is a Round view over a square view.
- set position: absolute for parent view (Parent)
- set position: relative for square view (child of parent)
- set position: relative for round view (child of parent)

Milan Chauhan
- 27
- 3
0
<View style={{ flex: 1, paddingTop: 50, backgroundColor: 'orange' }}>
<View style={{
height: 300,
width: "100%",
backgroundColor: 'red'
}}/>
<View
style={{
height: 300,
width: 300,
borderRadius: 150,
backgroundColor: 'white',
bottom: 300
}}
/>
</View>
I can think of two possibilities:
- You could have a
View
as a white circle and with position absolute, you can position it like that by also having a red rectangularView
and the white one comes on top of the red one (but here it is quite important how the rest of the screen looks like in - By using an svg triangle drawn like that (you can use react-native-svg for that)
<Svg style={{
height: '100%',
width: '100%',
backgroundColor: 'red'
}}>
<Path
stroke={2}
fill={'white'}
d={'M 100 126 l -101 -1 l 0 100 l -1 -2 l 1 2 q 13 -88 103 -99'}
/>
</Svg>

dianaqqq
- 633
- 6
- 12
-
Thanks for suggessions, I tried the first situtation you said but not work, white area is not transparent like this draw – Alisan26 May 07 '21 at 12:48
-
-
I used an svg editor (https://yqnn.github.io/svg-path-editor/) to obtain that shape and by changing the first two coordinates `M 100 126` you can move your curved triangle wherever you want – dianaqqq May 07 '21 at 13:01
-