Quick Tip Icon
Quick Tip

Avoiding text truncation in SwiftUI with Dynamic Type

When testing Breve with Dynamic Type, I noticed that in some layouts, text would get truncated at larger text sizes instead of wrapping onto the next line, even when there is no line limit and no vertical size constraint on the element. Text truncation can still occur even when the UI element containing the text is inside a scroll view and can grow infinitely.

iPhone screen showing a scroll view with coffee drink cards where the drink description is truncated iPhone screen showing a scroll view with coffee drink cards where the drink description is truncated

I had run into similar truncation issues before, but they seem to have become more frequent in iOS 26.

To ensure that text doesn't truncate, I had to apply the fixedSize(horizontal:vertical:) modifier to the text view, passing false for the horizontal parameter and true for the vertical one. This tells the text to respect horizontal size constraints so it wraps normally, while at the same time forcing it to ignore vertical constraints and expand as needed.

Text(drink.description)
    .fixedSize(
        horizontal: false,
        vertical: true
    )
iPhone screen showing a scroll view with coffee drink cards where the drink description is fully visible iPhone screen showing a scroll view with coffee drink cards where the drink description is fully visible

When using this workaround, make sure the layout can grow vertically as much as required, even at the largest accessibility sizes, so the text doesn't get cut off.

SwiftUI Fundamentals by Natalia Panferova book coverSwiftUI Fundamentals by Natalia Panferova book cover

Deepen your understanding of SwiftUI!$35

The essential guide to SwiftUI core concepts and APIs

SwiftUI Fundamentalsby Natalia Panferova

  • Explore the key APIs and design patterns that form the foundation of SwiftUI
  • Develop a deep, practical understanding of how SwiftUI works under the hood
  • Learn from a former Apple engineer who worked on widely used SwiftUI APIs

Deepen your understanding of SwiftUI!

The essential guide to SwiftUI core concepts and APIs

SwiftUI Fundamentals by Natalia Panferova book coverSwiftUI Fundamentals by Natalia Panferova book cover

SwiftUI Fundamentals

by Natalia Panferova

$35