Objective-c - TextKit path exclusion height calculation issue
大家讲道理
大家讲道理 2017-05-02 09:24:31
0
1
495

To implement path exclusion by inserting images into articles

UITextView dynamically calculates height using:
boundingRectWithSize:options:context:

However, this method is not compatible with path exclusion, and the height will be much smaller than the actual height. However, there is no problem using the sizeThatFits: method, but the performance of sizeThatFits: is really worrying

Do you have any good solutions


Code:

// 此方法获取的高度会小,只会计算文本高度,不会包含被路径排除的部分
CGRect textViewFrame = self.textView.frame;
CGSize maxSize = CGSizeMake(CGRectGetWidth(textViewFrame), MAXFLOAT);
CGRect frame = [self.textView.attributedText boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil];

// 此方法正常,但性能很差
CGSize size = [self.textView sizeThatFits:maxSize];
大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(1)
Peter_Zhu

http://stackoverflow.com/questions/19196758/calculate-cell-height-for-textview-with-exclusion-paths

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template