A view that displays one or more lines of read-only selectable text.
SelectableText
is a SwiftUI view designed to present text as read-only and selectable, filling a gap left by SwiftUI's standard Text
view which does not support text selection. It defaults to using a body font appropriate for the platform, but its true utility comes from its support for attributed text. This allows for detailed customization, enabling the direct application of varied text styles—such as font weights, sizes, and colors—within the text's attributes.
You can find the documentation here: https://kevinhermawan.github.io/SelectableText/documentation/selectabletext
You can add SelectableText
as a dependency to your project using Swift Package Manager by adding it to the dependencies value of your Package.swift
.
dependencies: [
.package(url: "https://github.com/kevinhermawan/SelectableText.git", .upToNextMajor(from: "1.0.0"))
]
Alternatively, in Xcode:
- Open your project in Xcode.
- Click on
File
->Swift Packages
->Add Package Dependency...
- Enter the repository URL:
https://github.com/kevinhermawan/SelectableText.git
- Choose the version you want to add. You probably want to add the latest version.
- Click
Add Package
.