---
title: NSTextViewportRenderingSurface
framework: uikit
role: symbol
role_heading: Protocol
path: uikit/nstextviewportrenderingsurface
---

# NSTextViewportRenderingSurface

A protocol that identifies a view or layer as a drawable element for a text layout fragment.

## Declaration

```swift
protocol NSTextViewportRenderingSurface : NSObjectProtocol
```

## Overview

Overview 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.

## Relationships

### Inherits From

- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Layout

- [Using TextKit 2 to interact with text](uikit/using-textkit-2-to-interact-with-text.md)
- [Display text with a custom layout](uikit/display-text-with-a-custom-layout.md)
- [Managing viewport layout and attachment reuse in text views](uikit/managing-viewport-layout-and-attachment-reuse-in-a-text-view-subclass.md)
- [NSTextLayoutManager](uikit/nstextlayoutmanager.md)
- [NSTextContainer](uikit/nstextcontainer.md)
- [NSTextLayoutFragment](uikit/nstextlayoutfragment.md)
- [NSTextLineFragment](uikit/nstextlinefragment.md)
- [NSTextViewportLayoutController](uikit/nstextviewportlayoutcontroller.md)
- [NSTextViewportRenderingSurfaceKey](uikit/nstextviewportrenderingsurfacekey.md)
- [NSTextLayoutOrientationProvider](uikit/nstextlayoutorientationprovider.md)
