ibireme / YYText

Powerful text framework for iOS to display and edit rich text.
MIT License
8.84k stars 1.67k forks source link

YYTextLayout中计算_lineWidth的代码直接使用了CTLineGetTypographicBounds,这将在文本设置居中的时候出现一些布局的错误 #983

Open CodeSlaveZhang opened 1 year ago

CodeSlaveZhang commented 1 year ago

文本的Paragraph Style设置居中,在计算布局的时候,左侧缩进后右侧并没有缩进。这将导致计算的结果实际上是居右的。

嘛 算了我描述好像不太清楚。总之就是设置居中看起来像是居右。 原始代码:


修改后的代码

新增了一个在有居中的情况下的补偿宽度。另外 _trailingWhitespaceWidth这个东西干啥用的,有点烟雾弹的效果- -。感觉像是你写漏了。