0

I have a text in a frame that can become too long depending on the user input. If a text is too long in SwiftUI, SwiftUI abbreviates it with "..." at the end. Example:

"That's a very long te..."

But now I want the last x characters to always be displayed, even if the text is too long. A good example of my wish is XCode itself:

Example

I'd be happy for help.

SwiftUI_Max
  • 201
  • 2
  • 6
  • 1
    Have a look at [truncationMode(_:)](https://developer.apple.com/documentation/swiftui/path/truncationmode(_:)) – vadian Apr 16 '22 at 10:07

1 Answers1

0

Use truncationMode(_:)

Example from link above, with .middle mode:

Text("This is a block of text that will show up in a text element as multiple lines. The text will fill the available space, and then, eventually, be truncated.")
    .frame(width: 150, height: 150)
    .truncationMode(.middle)
Alexander Sandberg
  • 1,265
  • 11
  • 19