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

标签 css react-native react-native-android react-native-ios

我正在开发一个示例应用程序,在这个应用程序中需要使用 Arrow 卡来提供显示卡。
我尝试过基于 native 形状的 react ,但我没有得到输出。

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

这是我的代码:

<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
}

这我需要像这种类型的图像,这是引用图像:

enter image description here

最佳答案

这就是我实现与您的图像几乎相同的方式。

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"
    }
});

世博链接https://snack.expo.io/rycpKiAe7

关于css - 我们如何在 react-native 中设计 Arrow 卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50804483/

相关文章:

html - 为什么在调整屏幕大小时我的图像会重新定位?

reactjs - React Native-如何在 React Native 中仅显示一次登录屏幕?

javascript - 从 Tab Navigator Tab Press 触发类函数调用 - React Native/Navigation

react-native - android的绝对位置

html - 如何防止 100vh 图像扩大视点?

html - 在特定样式表中以相对单位指定字体大小

html - Vue2 如何使用 $refs 定位元素并删除 css 类

typescript - React Native/Typescript - 错误模块 '"react-native "' has no exported member ' Pressable'.ts(2305)

react-native - 如何修复 : A problem occurred configuring project

reactjs - 如何从 React Native 上的 uri 获取图像高度和宽度?