<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/NSTextViewportRenderingSurface",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSTextViewportRenderingSurface"
  },
  "title" : "NSTextViewportRenderingSurface"
}
-->

# NSTextViewportRenderingSurface

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

```
protocol NSTextViewportRenderingSurface : NSObjectProtocol
```

## Overview

Conform a view or layer to `NSTextViewportRenderingSurface` to associate it with an [`NSTextLayoutFragment`](/documentation/UIKit/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`](/documentation/UIKit/NSTextViewportLayoutControllerDelegate).

### Implement a rendering surface

You can conform any `UIView`, `NSView`, or `CALayer` subclass to this protocol:

```swift
class TextFragmentView: UIView, NSTextViewportRenderingSurface {
    var layoutFragment: NSTextLayoutFragment?
}
```

Return instances from [`textViewportLayoutController(_:configureRenderingSurfaceFor:)`](/documentation/UIKit/NSTextViewportLayoutControllerDelegate/textViewportLayoutController(_:configureRenderingSurfaceFor:)) so TextKit can manage them during layout.

## Relationships

### Inherits From

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)