<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "QuartzCore",
  "identifier" : "/documentation/QuartzCore/CATextLayer",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Animation"
    ],
    "preciseIdentifier" : "c:objc(cs)CATextLayer"
  },
  "title" : "CATextLayer"
}
-->

# CATextLayer

A layer that provides simple text layout and rendering of plain or attributed strings.

```
class CATextLayer
```

## Overview

The first line is aligned to the top of the layer.

> Note:
> `CATextLayer` disables sub-pixel antialiasing when rendering text. Text can only be drawn using sub-pixel antialiasing when it is composited into an existing opaque background at the same time that it’s rasterized. There is no way to draw text with sub-pixel antialiasing by itself, whether into an image or a layer, in advance of having the background pixels to weave the text pixels into. Setting the `opacity` property of the layer to <doc://com.apple.documentation/documentation/Swift/true> does not change the rendering mode.

> Note:
> In macOS, when a `CATextLayer` instance is positioned using the ``doc://com.apple.quartzcore/documentation/QuartzCore/CAConstraintLayoutManager`` class the bounds of the layer is resized to fit the text content.

## Topics

### Getting and Setting the Text

[`string`](/documentation/QuartzCore/CATextLayer/string)

The text to be rendered by the receiver.

### Text Visual Properties

[`font`](/documentation/QuartzCore/CATextLayer/font)

The font used to render the receiver’s text.

[`fontSize`](/documentation/QuartzCore/CATextLayer/fontSize)

The font size used to render the receiver’s text. Animatable.

[`foregroundColor`](/documentation/QuartzCore/CATextLayer/foregroundColor)

The color used to render the receiver’s text. Animatable.

[`allowsFontSubpixelQuantization`](/documentation/QuartzCore/CATextLayer/allowsFontSubpixelQuantization)

Determines whether to allow subpixel quantization for the graphics context used for text rendering.

### Text Alignment and Truncation

[`isWrapped`](/documentation/QuartzCore/CATextLayer/isWrapped)

Determines whether the text is wrapped to fit within the receiver’s bounds.

[`alignmentMode`](/documentation/QuartzCore/CATextLayer/alignmentMode)

Determines how individual lines of text are horizontally aligned within the receiver’s bounds.

[`truncationMode`](/documentation/QuartzCore/CATextLayer/truncationMode)

Determines how the text is truncated to fit within the receiver’s bounds.

### Constants

[Truncation modes](/documentation/QuartzCore/truncation-modes)

These constants are used by the [`truncationMode`](/documentation/QuartzCore/CATextLayer/truncationMode) property.

[Horizontal alignment modes](/documentation/QuartzCore/horizontal-alignment-modes)

These constants are used by the [`alignmentMode`](/documentation/QuartzCore/CATextLayer/alignmentMode) property.



---

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)