我们如何在 react-native 中设计 Arrow card

How can we design Arrow card in react-native

我正在开发一个示例应用程序,在这个应用程序中需要使用Arrow card 来提供展示卡。 我试过 react-native shapes based ,但我没有得到结果。

假设如果提供的文本自动增加,箭头设计形状也会增加

这是我的代码:

<View style={styles.container}>
                <View style={{ flex: 0.1, backgroundColor: "blue" }} />
                <View
                    style={{
                        flex: 0.9,
                        backgroundColor: "green",
                        justifyContent: "center",
                        alignItems: "center"
                    }}
                >
                    <View style={styles.baseTop} />
                    <View style={styles.baseBottom} />
                </View>
            </View>
baseTop: {
    borderBottomWidth: 35,
    borderBottomColor: "red",
    borderLeftWidth: 50,
    borderLeftColor: "transparent",
    borderRightWidth: 50,
    borderRightColor: "transparent",
    height: 0,
    width: 0,
    left: 0,
    top: -35,
    position: "absolute"
},
baseBottom: {
    backgroundColor: "red",
    height: 55,
    width: 100
}

我需要这种类型的图片这是参考图片:

您可以制作一个弹性正方形,使用 Transform 旋转它,然后将其绝对定位到正确的位置。

或者您可以使用 react-native-svg 并创建一个 SVG,然后相应地定位它。

我就是这样实现的,几乎和你的图片一样。

import React, { Component } from 'react';
import { Text, View,StyleSheet } from "react-native";

export default class App extends Component {
  render() {
       return (
           <View style={{flex:1}}>
             <View
                style={styles.wrapper}>
                <View style={styles.rectangle}><Text>6</Text> <Text>tens</Text> </View>
                <View style={styles.rectangle}><Text>6</Text> <Text>ones</Text> </View>>
                 <View style={styles.triangle}></View>

            </View>
           </View>
        );
  }
}

const styles = StyleSheet.create({
    wrapper: {
        flexDirection: "row",
        justifyContent: "flex-start",
        flex: 0.2,
        alignItems: "center",
        paddingLeft: 29,
        paddingTop: 0,
        marginTop: 0

    },
    rectangle: {
        width: 50,
        backgroundColor: "yellow",
        margin: 0,
        justifyContent: "center",
        alignItems: "center",
        height: 52,
        borderColor:"black"

    },
    triangle: {
        width: 0,
        height: 0,
        backgroundColor: 'transparent',
        borderStyle: 'solid',
        borderLeftWidth: 27,
        borderRightWidth: 27,
        borderBottomWidth: 43,
        borderLeftColor: 'transparent',
        borderRightColor: 'transparent',
        borderBottomColor:"yellow",
        transform: [
            { rotate: '90deg' }
        ],
        margin: 0,
        marginLeft: -6,
        borderWidth: 0,
        borderColor:"black"
    }
});

博览会linkhttps://snack.expo.io/rycpKiAe7