React Native组件解析(二)之Text
React Native组件解析(二)之Text
1. 概述
Text组件对应于iOS的UILabel,Android的TextView,用来显示文本。但是Text组件的内部使用的并不是flexbox布局,而是文本布局,所以如果想要使文字居中,需要在Text组件的外层套一层View,设置View的flexbox
1.1 字体相关 Style属性
| Style属性名 | 取值 | 说明 |
|---|---|---|
| fontFamily | enum('sans-serif', 'serif','monospace','sans-serif-light','sans-serif-thin','sans-serif-condensed','sans-serif-medium') | 英文字符串的样式 |
| fontSize | number | 字体大小 |
| fontStyle | enum('normal', 'italic') | 字体风格是普通还是斜体 |
| fontWeight | enum('normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900') | 字体粗细程度 |
1.2 阴影相关 Style属性
| Style属性名 | 取值 | 说明 |
|---|---|---|
| textShadowColor | color | 阴影颜色 |
| textShadowOffset | {width: number, height: number} | 阴影效果 |
| textShadowRadius | number | 阴影圆角 |
1.3 阴影相关 Style属性
| Style属性名 | 取值 | 说明 |
|---|---|---|
| textAlign | enum('auto', 'left', 'right', 'center', 'justify') | 对齐方式 |
| textDecorationLine | enum('none', 'underline', 'line-through', 'underline line-through') | 横线相关设置 |
| lineHeight | number | 行高 |
| numberOfLines | number | 行数,同iOS,0:不限制行数 |
| adjustsFontSizeToFit | bool | 默认值为false,为true时字体会自动缩小,以适应给定的样式约束 |
| minimumFontScale | number | 为true时,设置字体的最小缩放比例,取值范围为0.01~1.0 |
1.3 阴影相关 Style属性
| Style属性名 | 取值 | 说明 |
|---|---|---|
| onPress | function | 点击回调 |
| onLongPress | function | 长按回调 |
具体可查看相关官方APIText
React Native组件解析(二)之Text的更多相关文章
- React Native组件(三)Text组件解析
相关文章 React Native探索系列 React Native组件系列 前言 此前介绍了最基本的View组件,接下来就是最常用的Text组件,对于Text组件的一些常用属性,这篇文章会给出简单的 ...
- React Native组件(二)View组件解析
相关文章 React Native探索系列 React Native组件系列 前言 了解了RN的组件的生命周期后,我们接着来学习RN的具体的组件.View组件是最基本的组件,也是首先要掌握的组件,这一 ...
- React Native组件之Text
React Native组件之Text相当于iOS中的UILabel. 其基本属性如下: /** * Sample React Native App * https://github.com/face ...
- 【React Native 实战】二维码扫描
1.前言今天介绍React Native来实现二维码扫描的功能.首先我们要借助第三方插件react-native-barcode-scanner-universal来实现跨平台二维码扫描. 2.介绍 ...
- beeshell —— 开源的 React Native 组件库
介绍 beeshell 是一个 React Native 应用的基础组件库,基于 0.53.3 版本,提供一整套开箱即用的高质量组件,包含 JavaScript(以下简称 JS)组件和复合组件(包含 ...
- react native组件的生命周期
react native组件的生命周期 一.当页面第一次加载时,会依次调用: constructor() componentWillMount(): 这个函数调用时机是在组件创建,并初始化了状态之后, ...
- react native组件的创建
react native组件的创建 react文件加载顺序: react项目启动后,先加载index.js.在index.js中可以指向首页. import { AppRegistry } from ...
- 【RN - 基础】之React Native组件的生命周期
下图描述了React Native中组件的生命周期: 从上图中可以看到,React Native组件的生命周期可以分为初始化阶段.存在阶段和销毁阶段. 实例化阶段 实例化阶段是React Native ...
- React Native组件之Switch和Picker和Slide
React Native组件Switch类似于iOS中的UISwitch:组件Slide类似于iOS中UIslider,组件Picker类似于iOS的UIPickerView.他们的使用方法和相关属性 ...
随机推荐
- bzoj 5056: OI游戏 最短路树的计数
OI游戏 Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 196 Solved: 159[Submit][Status][Discuss] Descrip ...
- element-ui 的 upload组件的clearFiles方法调用方法
<template> <div> <el-button @click="clearUploadedImage">重新上传</el-butt ...
- vue slot 插槽备忘
老是记不住插槽咋回事 记录下来备忘 父组件 <tab><template slot="boy" slot-scope="test">{{ ...
- 在tomcat发布项目遇到的问题
今天从SVN上把系统导入本地发生了异常,问题如下: java.math.BigInteger cannot be cast to java.lang.Long 百度一番后发现是因为使用Mysql8.0 ...
- configure.ac:3: error: Autoconf version 2.68 or higher is required
configure.ac:3: error: Autoconf version 2.68 or higher is required 参考博客:https://blog.csdn.net/pretty ...
- AC日记——Andryusha and Socks Codeforces 780a
A. Andryusha and Socks time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- (1)TensorFlow 概要
TensorFlow:翻译成中文 张量流 计算图:又被称为有向图.数据流图 数据流图用结点和线的有向图来描述数学计算,节点一般用来表示施加的数学操作,也可以用来数据输入起点.输出终点,或者读取写入持久 ...
- 虚拟机centos 同一个tomcat、不同端口访问不同的项目
在tomcat中复制webapps目录,并重命名:
- php 打印今天,昨天,本周,上周,当月,上月,本季,上季,今年,去年数据
if($filter['mode']) { switch ($filter['mode']) { case 1://今天的数据 $time_start = date("Y-m-d H:i:s ...
- Windows Server 2008R2 设置SMTP邮件转发服务
最近因业务需求在Windows Server 2008R2server上设置SMTP转发服务,主要是在业务审批过程中邮件通知相关人员审批情况, 1.在server上加入服务 2.打开服务 3.新建一个 ...