CTFrameGetVisibleStringRange Incorrectly Counting

2019-09-06 22:06发布

问题:

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?

回答1:

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.