首页 > 其他 > 详细

React-Native组件之Text内文字垂直居中方案

时间:2018-11-20 16:59:52      阅读:1062      评论:0      收藏:0      [点我收藏+]
1 style: {
2   height: 100,
3   textAlign: ‘center‘,
4   textAlignVertical: ‘center‘,  
5 }

以上方法在Android上显示水平垂直居中, 但在IOS上只能水平居中, 方法是在IOS上添加lineHeight: 100, 如下

1 style: {
2   height: 100,
3   textAlign: ‘center‘,
4   textAlignVertical: ‘center‘,
5   ...Platform.select({
6      ios: { lineHeight: 100},
7      android: {}
8    })
9 }

别忘了在react-native模块中导入组件 StyleSheet和Platform

React-Native组件之Text内文字垂直居中方案

原文:https://www.cnblogs.com/hughes5135/p/9989867.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!