I have to find the number of lines of a UITextView
. There is no property available, like anumberOfLines
, on UITextView
. I use the f
If you are using iOS 3, you need to use the leading
property:
int numLines = txtview.contentSize.height / txtview.font.leading;
If you are using iOS 4, you need to use the lineHeight
property:
int numLines = txtview.contentSize.height / txtview.font.lineHeight;
And, as @thomas pointed out, be careful of rounding if you need an exact result.