我正在使用UITextView
和NSAttributedString
创建一款阅读应用程序,我需要将整个属性字符串拆分成较小数量的属性字符串,以实现分页概念。
我有一个计算给定属性字符串框架大小的方法。
CGRect rect = [attrString boundingRectWithSize:CGSizeMake(768, 10000) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil];
但我需要获取 (768, 1024) ContentSize 的 attributeString。
我已经使用了这个方法,但是 attributedStrings 没有正确地分割,因为它包含了 NSTextAttachment
和 HTML
字符串。
CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)delegate.attributedString);
我该如何计算这个?计算需要快速且占用内存较小。