Quick Tip Icon
Quick Tip

Set custom actions for links in Text views

Since iOS 15 and macOS 12 SwiftUI Text views can contain interactive links created with Markdown or AttributedString.

To customize actions of such links we can use openURL environment value.

struct ContentView: View {
    var body: some View {
        Text("Visit our [website](https://example.com)")
            .environment(\.openURL, OpenURLAction { url in
                return .handled
    func handleURL(_ url: URL) {
        // handle URL here
Integrating SwiftUI into UIKit Apps by Natalia Panferova book coverIntegrating SwiftUI into UIKit Apps by Natalia Panferova book cover

Check out our book!

Integrating SwiftUI into UIKit Apps

Integrating SwiftUI intoUIKit Apps


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