In your content view. Set AutoLayout to readable layout guide and make sure call:
preservesSuperviewLayoutMargins = true
Post
Replies
Boosts
Views
Activity
Just make a simple debugging for this.
height = max(height, contentSize.height) is not required and should be removed from sample codes. Now the layout is the correct size.
I have the same issue about the paragraph spacing for the fragments. It looks like the NSParagraphStyle does not works for TextKit 2.
Finally, I use a new subclass for NSTextLayoutFragment and override the bottomMargin to the spacing.
extension TextAreaView: NSTextLayoutManagerDelegate {
func textLayoutManager(_ textLayoutManager: NSTextLayoutManager, textLayoutFragmentFor location: NSTextLocation, in textElement: NSTextElement) -> NSTextLayoutFragment {
let endTextLocation = textLayoutManager.documentRange.endLocation
if let elementRangeEndLocation = textElement.elementRange?.endLocation,
elementRangeEndLocation.compare(endTextLocation) == .orderedSame {
return NSTextLayoutFragment(textElement: textElement, range: textElement.elementRange)
} else {
return ParagraphTextLayoutFragment(textElement: textElement, range: textElement.elementRange)
}
}
}
Maybe we could add some view during surfacing drawing due to the NSTextLayoutFragment could be customized by subclassing. I'm working on adding a custom view inline. And still needs some efforts.
Same issue. Cannot release new build. :(