2016-11-28 2 views
0

어떻게 알 수 있습니까? UITextView 공간 부족으로 문자가 짧아 집니까? 나는 boundingRectWithSizesizeThatFit으로 계산할 수 있지만, UITextViewexclusionPaths을 변경하면 어떨까요? 다각형에 문자열을 배치하고 단축하지 않고 문자열을 배치 할 때까지 다각형 크기를 늘려야합니다. 어떤 아이디어라도 부울 반환 방법은 현재 설치가 짧아 질 것입니까?UITextView는 텍스트를 줄입니까?

self.tv.textContainer.exclusionPaths = myArrayOfBezierPaths; 
+0

[당신이이 글을 읽을습니까?] (http://stackoverflow.com/a/19917287/312312) – Lefteris

답변

2
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 
}