YYText icon indicating copy to clipboard operation
YYText copied to clipboard

YYTextContainer 的 truncationToken 在子线程中生成的问题

Open slemon opened this issue 8 years ago • 1 comments

为了优化列表的性能,把文本的 layout计算放在子线程,如果文本后面需要自定义 truncationToken,(用 uiview 做truncationToken),可能是因为是在子线程中生成truncationToken,展示的时候 truncationToken 一开始是空白的,但如果做一次页面切换,truncationToken就显露出来,这种情况请问YY有什么好的解决方法吗?能否把 truncationToken 和 layout 的计算分开放到不同线程中?

第一次出现: image 切换页面后: image 子线程中的代码如下: image

slemon avatar May 01 '17 09:05 slemon

我暂时通过以下方式解决,仅供参考。 在子线程创建textLayout,主线程创建 textLabel,truncationToken。 还是需要等@ibireme 修改来解决该问题。

YYTextLayout *textLayout;
YYTextLabel *textLabel;
textLabel.ignoreCommonProperties = NO;
textLabel.textLayout =  textLayout;
NSAttributedString *truncationToken;
textLabel.truncationToken = truncationToken;

cozelight avatar May 12 '17 04:05 cozelight