xcode - Swift 3 - UITextView total line counter -
good day hope well.
this possibly seems repeat question nothing working me.
i have looked @ multiple instances of question , have tried many different things , doesn't solve problem.
i have textview constrained 11 lines , becomes scrollable..... want total line count of text content not display size on screen solutions provide me 11 lines true line count +- 30 lines.even if show 5 lines of text returns 11
how can find out line count of text collectivly.
any appreciated
use extension solve problem!
extension string { func lines(font : uifont, width : cgfloat) -> int { let constraintrect = cgsize(width: width, height: .greatestfinitemagnitude); let boundingbox = self.boundingrect(with: constraintrect, options: .useslinefragmentorigin, attributes: [nsfontattributename: font], context: nil); return int(boundingbox.height/font.lineheight); } }
Comments
Post a Comment