You need to use the lineHeight
property, and font lineHeight
:
Objective-C
int numLines = txtview.contentSize.height / txtview.font.lineHeight;
Swift
let numLines = (txtview.contentSize.height / txtview.font.lineHeight) as? Int
I am getting correct number of lines.