简体   繁体   English

带有中心文本的圆形形状不起作用 React Native iOS

[英]Circle shape with center text not working React Native iOS

I am trying to drawing circle shape view for textview inside that some text.我正在尝试在一些文本中为 textview 绘制圆形视图。

It is working with Android, But, iOS not working properly.它与 Android 一起使用,但是,iOS 无法正常工作。 Text is coming top of the view.文本出现在视图顶部。

      <Text style={styles.na}> NA </Text>

styles


 na: {
    width: 60,
    height: 60,
    borderRadius: 60 / 2,
    backgroundColor: 'orange',
    alignItems: 'center',
    textAlign: 'center',
    fontWeight: 'bold',
    color: 'white',
    fontSize: 15,
    textAlignVertical: 'center',
    marginRight: 10,
    overflow: 'hidden',
  },

Any suggestions?有什么建议么?

在此处输入图像描述

try this code, works for me试试这个代码,对我有用

      <View style={{
        width: 60,
        height: 60,
        justifyContent: "center",
        borderRadius: 60 / 2,
        backgroundColor: 'orange',
      }}>
        <Text style={{
          alignSelf: 'center',
          fontWeight: 'bold',
          color: 'white',
          fontSize: 15,
        }}>NA</Text>
      </View>

try alignSelf: center尝试alignSelf: center

alignSelf has the same options and effect as alignItems but instead of affecting the children within a container, you can apply this property to a single child to change its alignment within its parent. alignSelf 具有与 alignItems 相同的选项和效果,但不影响容器中的子项,您可以将此属性应用于单个子项以更改其父项中的 alignment。 alignSelf overrides any option set by the parent with alignItems. alignSelf 使用 alignItems 覆盖父级设置的任何选项。

Reference参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM