1.在Unity.UIWidgets.widgets下
2.构造方法
public Text(string data,//数据 Key key = null,//唯一id TextStyle style = null,//文本样式 TextAlign? textAlign = null,//文本对齐方式 bool? softWrap = null,//某一行中文本过长,是否需要换行。默认为true,如果为false,则文本中的字形将被定位为好像存在无限的水平空间。 TextOverflow? overflow = null,//文本超出后处理方式 float? textScaleFactor = null,//每个逻辑像素的字体像素数 int? maxLines = null//文本要跨越的可选最大行数, )
3.TextStyle
public TextStyle( bool inherit = true,//是否继承 Color color = null, //文本颜色 float? fontSize = null,//文本大小 FontWeight fontWeight = null,//文本样式 /* FontWeight.bold 常用的字体重量比正常重。即w700 FontWeight.normal 默认字体粗细。即w400 FontWeight.w100 薄,最薄 FontWeight.w200 特轻 FontWeight.w300 轻 FontWeight.w400 正常/普通/平原 FontWeight.w500 较粗 FontWeight.w600 半粗体 FontWeight.w700 加粗 FontWeight.w800 特粗 FontWeight.w900 最粗 */ FontStyle? fontStyle = null,//文本样式 /* FontStyle.italic 使用斜体 FontStyle.normal 使用直立 */ float? letterSpacing = null, //水平字母之间的空间间隔(逻辑像素为单位) float? wordSpacing = null,//单词之间添加的空间间隔(逻辑像素为单位) TextBaseline? textBaseline = null, //对齐文本的水平线,TextBaseline.alphabetic:文本基线是标准的字母基线TextBaseline.ideographic:文字基线是表意字基线;如果字符本身超出了alphabetic 基线,那么ideograhpic基线位置在字符本身的底部。 float? height = null, //行高 Paint background = null,//背景色 TextDecoration decoration = null,//文本装饰:下划线(TextDecoration.underline)上划线(TextDecoration.overline)删除线(TextDecoration.lineThrough)无(TextDecoration.none) Color decorationColor = null, //文本装饰的颜色。 TextDecorationStyle? decorationStyle = null,//绘制文本装饰的样式 /* 绘制文本装饰的样式: 画两条线 TextDecorationStyle.double 画一条实线 TextDecorationStyle.solid */ string fontFamily = null, //字体库 string debugLabel = null//描述文字 )
4.静态方法Text.rich
public static Text rich( TextSpan textSpan,//文本字段 Key key = null,//唯一id TextStyle style = null,//文本样式 TextAlign? textAlign = null,//文本对齐方式 bool? softWrap = null,//某一行中文本过长,是否需要换行。默认为true,如果为false,则文本中的字形将被定位为好像存在无限的水平空间。 TextOverflow? overflow = null,//文本超出后处理方式 float? textScaleFactor = null,//每个逻辑像素的字体像素数 int? maxLines = null//文本要跨越的可选最大行数, )
5.RichText
/// <summary> /// /// </summary> /// <param name="key">唯一id</param> /// <param name="text">文本字段</param> /// <param name="textAlign">文本对齐方式</param> /// <param name="softWrap">某一行中文本过长,是否需要换行。默认为true,如果为false,则文本中的字形将被定位为好像存在无限的水平空间。</param> /// <param name="overflow">文本超出后处理方式</param> /// <param name="textScaleFactor">每个逻辑像素的字体像素数</param> /// <param name="maxLines">文本要跨越的可选最大行数,</param> /// <param name="onSelectionChanged">文字选择回调</param> /// <param name="selectionColor">选中颜色</param> public RichText( Key key = null, TextSpan text = null, TextAlign textAlign = TextAlign.left, bool softWrap = true, TextOverflow overflow = TextOverflow.clip, float textScaleFactor = 1.0f, int? maxLines = null, Action onSelectionChanged = null, Color selectionColor = null )
5.参考:https://blog.csdn.net/chenlove1/article/details/84574651