CTFrameGetVisibleStringRange错误地计算字符串末尾的空格? [英] CTFrameGetVisibleStringRange Incorrectly Counting Spaces at End of String?

查看:161
本文介绍了CTFrameGetVisibleStringRange错误地计算字符串末尾的空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 CoreText ,我注意到 CTFrameGetVisibleStringRange 错误地对字符串末尾的空格进行计数,在框架中不可见。仅供参考,我在 NSMutableAttributedString 的末尾使用 insertAttributedString 作为字符串@添加空格。有人知道如何解决这个问题吗?

I'm working with CoreText and I notice that CTFrameGetVisibleStringRange incorrectly counts spaces at the end of the string which are NOT visible in the frame as being visible. FYI, I am adding the space as a string @" " using insertAttributedString to the end of my NSMutableAttributedString. Does anyone know how to fix this?

更新:仍然没有找到解决方案,这是预期的行为吗?还是这只是一个错误?

UPDATE: Still haven't found a solution to this, is this the intended behavior? Or this just a bug?

推荐答案

这是一个错误。要解决此问题,请用其他方法替换字符串末尾的,执行所需的操作,然后在末尾重新插入。

This is a bug. To work around this replace the " " at the end of the string with something else, do whatever you need to do, then reinsert the " " at the end.

这篇关于CTFrameGetVisibleStringRange错误地计算字符串末尾的空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆