How to get CATextLayer’s wrapping count in order to calculate height

孤人 提交于 2019-12-07 03:51:27

I assume that CATextLayer internally uses Core Text for layout, so you could do the same and use CTFramesetterSuggestFrameSizeWithConstraints to calculate an appropriate height for an attributed string with a given width.

Well, I ended up forgoing CATextLayer's wrapping behavior and doing my own line breaks -- which I would have had to do in this case anyway because I'm using different fonts for different lines, causing variations in their size.

But I don't understand why CATextLayer doesn't allow access to what its wrapping functions are doing -- either adding the line breaks to the string property itself, which we could then access, or simply providing a "lineCount" read-only accessor.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!