如何知道 UITextView
是否会因为空间不足而缩短文本?我知道我可以使用 boundingRectWithSize
和 sizeThatFit
进行计算,但是如果 UITextView
的 exclusionPaths
发生变化怎么办。我想在多边形中布置字符串,并增加多边形大小,直到布置字符串而不缩短。任何想法,如何获得 bool 返回,当前设置是否会缩短?
self.tv.textContainer.exclusionPaths = myArrayOfBezierPaths;
最佳答案
func isSizeFitForTextView() -> Bool{
let layoutManager = self.textView.layoutManager
let glyphIndex = layoutManager.glyphIndexForCharacter(at:( self.textView.text as NSString).length)
let range = layoutManager.truncatedGlyphRange(inLineFragmentForGlyphAt: glyphIndex)
return range.location != NSNotFound
}
关于ios - UITextView 会缩短文本吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40841898/