what is new in SwiftUI Text views in iOS 18

Asked on 08/01/2024

1 search

In iOS 18, SwiftUI Text views have received several notable updates:

  1. Programmatic Text Selection: SwiftUI now offers programmatic access to and control of text selection within text editing controls. This allows you to read properties of the selection, such as the selected ranges, and use this information to enhance user interactions, like showing suggested rhymes for selected words.

  2. Text Suggestions: You can now add text suggestions to any text field. These suggestions appear as a dropdown menu, and selecting an option updates the text field with the chosen completion.

  3. Custom Text Drawing: SwiftUI introduces the ability to customize how text is drawn for an entire view tree, enabling a range of custom text drawing possibilities, including animations. The core of this feature is the drawLayout method in the text renderer protocol, which allows access to individual components of the text, such as lines, runs, and glyphs.

  4. Improved Accessibility: SwiftUI has enhanced its accessibility features, allowing you to add additional information to built-in accessibility labels without overriding the framework-provided label.

For more details, you can refer to the session What’s new in SwiftUI (15:06).

Relevant Sessions