ibireme / YYText

Powerful text framework for iOS to display and edit rich text.
MIT License
8.84k stars 1.69k forks source link

有没有方法可以获取一段文字在固定宽度的情况下,总共有多少行? #870

Open snsdev1 opened 5 years ago

Auk513 commented 5 years ago

CGSize maxSize = CGSizeMake(width, MAXFLOAT); NSAttributedString attributedString = @"attributed string"; YYTextContainer textContainer = [YYTextContainer containerWithSize:maxSize]; YYTextLayout *layout = [YYTextLayout layoutWithContainer:textContainer text:attributedString]; NSInteger rowCount = layout.rowCount;