Re: iOS: selectable but not editable text


Gerriet M. Denkmann
 

On 12 Apr 2022, at 22:32, Quincey Morris <quinceymorris@...> wrote:

https://developer.apple.com/documentation/swiftui/view/textselection(_:)
That is exactly what I was missing when I started this project to years ago in macOS 10.15.4.
textSelection Availability macOS 12.0+

One minor problem:

HStack
{
Text(“One Red”)
.foregroundColor(.red)

Text(“Two Brown”)
.foregroundColor(.brown)
}
.textSelection(.enabled)
.padding(5)

When I triple-click inside my text line, only one colour gets selected.
Probably I need one attributed string with several colours and one Text.

Thanks a lot for your help!

Gerriet.

Join {cocoa@apple-dev.groups.io to automatically receive all group messages.