Type Property 型プロパティ

enabled

A selectability value that enables text selection by a person using your app.

Declaration 宣言

static var enabled: EnabledTextSelectability { get }
Available when Self is EnabledTextSelectability.

Discussion 議論

Enabling text selection allows people to perform actions on the text content, such as copying and sharing. Enable text selection in views where those operations are useful, such as copying unique IDs or error messages. This allows people to paste the data into emails or documents.

The following example enables text selection on the second of two Text views in a VStack.


VStack {
    Text("Event Invite")
        .font(.title)
    Text(invite.date.formatted(date: .long, time: .shortened))
        .textSelection(.enabled)
}

See Also 参照

Getting Selectability Options