What’s new attributed string

Asked on 08/05/2024

1 search

Apple introduced several new features related to attributed strings at WWDC 2024. Here are some highlights:

  1. Text Attribute Protocol: In the session Create custom visual effects with SwiftUI, a new text attribute protocol was introduced alongside the text renderer in iOS 18. This protocol allows developers to pass data from their text to the text renderer, enabling custom visual effects.

  2. Text Highlighting: The session What’s new in AppKit discussed new text highlighting features controlled by attributed string attributes. The texthighlight attribute corresponds to a texthighlightstyle, which can be set to system default or customized with a color scheme.

  3. Text Highlight Feature in UIKit: Similarly, the session What’s new in UIKit introduced a new text highlight feature for UIKit. It uses texthighlightstyle and texthighlight color scheme attributes to render highlighted text with predefined or custom color schemes.

  4. Attributed Strings in Multilingual Apps: In the session Build multilingual-ready apps, it was highlighted that using color attributes in attributed strings can help differentiate parts of the text, especially in multilingual contexts where bold or italic styles may not be visually distinct.

  5. Genmoji and Attributed Strings: The session Bring expression to your app with Genmoji explained how Genmoji, which are handled using attributed strings, can be integrated into custom text engines built with Textkit and Coretext.

These updates provide developers with more tools to create rich text experiences across Apple's platforms.