Reputation: 35038
How to know wether UITextView
will shorten text because lack of space? I know I can calculate with boundingRectWithSize
and sizeThatFit
, but what if exclusionPaths
of the UITextView
is changed. I want lay out string in a polygon, and increase polygon size, until string laid out without shortening. Any idea, how can get a bool return, wether current setup will shorten?
self.tv.textContainer.exclusionPaths = myArrayOfBezierPaths;
Upvotes: 0
Views: 389
Reputation: 6885
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
}
Upvotes: 2