React-native Text文字垂直居中的问题

2021-10-08  本文已影响0人  晨阳Xia

React-native中文字垂直居中的坑

iPhoneX 设置了 justifyContent 居中,但是iPhone12promax不居中解决方案
在Text外部包裹一层view,flex属性放在view里,文字属性放在textstyle里

代码示例

<View style={styles.textSuperViewStyle}>
              <Text style={styles.textStyle} numberOfLines={1}>
                { tipList[0] }
              </Text>
            </View>

textSuperViewStyle: {
    flex: 1,
    height: scale(defaultHeight, true),
    lineHeight: scale(defaultHeight, true),
    position: 'absolute',
    left: positionLeft + 20,
    right: positionRight + 14,
    justifyContent: 'center'
  },

  textStyle: {
    color: '#FF6600',
    fontSize: 12
  }
上一篇 下一篇

猜你喜欢

热点阅读