How to create tappable url/phone number in SwiftUI

前端 未结 6 1335
Happy的楠姐
Happy的楠姐 2021-01-04 10:06

I would like to display a phone number in a SwiftUI Text (or any View), and then make it clickable so that it will open the \'Phone\'.

Is there a way to do this with

6条回答
  •  既然无缘
    2021-01-04 11:01

    Using iOS 14 / Xcode 12.0 beta 5

    Use new link feature in SwiftUI for phone and email links.

        // Link that will open Safari on iOS devices
        Link("Apple", destination: URL(string: "https://www.apple.com")!)
        
        //  Clickable telphone number
        Link("(800)555-1212", destination: URL(string: "tel:8005551212")!)
    
        //  Clickable Email Address
        Link("apple@me.com", destination: URL(string: "mailto:apple@me.com")!)
        
    

提交回复
热议问题