Enable text selection for non-editable text
This modifier can be set on each
Text view individually or on a hierarchy of views to enable text selection for all
Text in the hierarchy.
// Contents of the Text view
// will be selectable
// Contents of each Text view
// will be selectable individually
Even when we set
.textSelection(.enabled) on a hierarchy of views, each
Text view will still be individually selectable. There is no way to select contents of multiple
Text views at the same time.
On macOS users can select a range of text using the mouse. On iOS it's only possible to select the entire contents of a
Text view by long pressing on it and summoning the system menu with context appropriate actions such as
Check out our book!
Integrating SwiftUI into UIKit Apps
Integrating SwiftUI intoUIKit Apps
UPDATED FOR iOS 17!
A detailed guide on gradually adopting SwiftUI in UIKit projects.
- Discover various ways to add SwiftUI views to existing UIKit projects
- Use Xcode previews when designing and building UI
- Update your UIKit apps with new features such as Swift Charts and Lock Screen widgets
- Migrate larger parts of your apps to SwiftUI while reusing views and controllers built in UIKit