NSTextViewportRenderingSurface
A protocol that identifies a view or layer as a drawable element for a text layout fragment.
Declaration
protocol NSTextViewportRenderingSurface : NSObjectProtocolOverview
Conform a view or layer to NSTextViewportRenderingSurface to associate it with an NSTextLayoutFragment during viewport layout. TextKit uses this to track, configure, and reuse visual elements across layout passes.
This protocol has no required methods. It gives TextKit a way to identify and manage the visual elements your delegate provides through NSTextViewportLayoutControllerDelegate.
Implement a rendering surface
You can conform any UIView, NSView, or CALayer subclass to this protocol:
class TextFragmentView: UIView, NSTextViewportRenderingSurface {
var layoutFragment: NSTextLayoutFragment?
}Return instances from textViewportLayoutController(_:configureRenderingSurfaceFor:) so TextKit can manage them during layout.