Objective C - UITextView行数

时间:2015-04-09 22:41:50

标签: ios objective-c textview

我有问题。 我想知道如何在文本视图中获取文本的WRITTEN行的确切数量。 我不希望行数可行,但是那些已被字符使用和填充的行。

例如:

In this case the result is 2. In this case the result is 3.

1 个答案:

答案 0 :(得分:0)

你可以尝试按照

的方式行事
[textField sizeToFit]; //Get the minimum height and width for the text
NSInteger numLines = textField.frame.size.height / textField.font.lineHieght

但是我自己没有尝试过