Want to create a diagonal border in React Native? You can apply css to View class and create the desired output, Heres a small demo code edited version.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | import React, { Component } from 'react'; import { View, StyleSheet } from 'react-native'; import { Constants } from 'expo'; export default class App extends Component { render() { return ( <View style={styles.container}> <View style={styles.triangleCorner}></View> <View style={styles.triangleCornerLayer}></View> <View style={styles.triangleCorner1}></View> </View> ); } } const styles = StyleSheet.create({ container: { flex: 1, alignItems: 'center', justifyContent: 'center', paddingTop: Constants.statusBarHeight, backgroundColor: '#ecf0f1', },triangleCorner: { position: 'absolute', top:105, left:0, width: 300, height: 100, backgroundColor: 'transparent', borderStyle: 'solid', borderRightWidth: 50, borderTopWidth: 80, borderRightColor: 'transparent', borderTopColor: 'gray' },triangleCorner1: { position: 'absolute', top:100, left:0, width: 130, backgroundColor: 'transparent', borderStyle: 'solid', borderRightWidth: 50, borderTopWidth: 90, borderRightColor: 'transparent', borderTopColor: 'green' },triangleCornerLayer: { position: 'absolute', top:107, left:0, width:297, height: 100, backgroundColor: 'transparent', borderStyle: 'solid', borderRightWidth: 47, borderTopWidth: 75, borderRightColor: 'transparent', borderTopColor: 'white' } }); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.