如何使用SwiftUI拨打电话

问题描述 投票:0回答:1

如何在SwiftUI中拨打电话。这是Swift和UIKit的示例代码:

guard let number = URL(string: "tel://" + "+1(222)333-44-55") else { return }
UIApplication.shared.open(number)

这里是Swift和UIKit版本的线程:

How to make phone call in iOS 10 using Swift?

swift uikit swiftui
1个回答
0
投票
let numberString = "111-222-3334"

Button(action: {
    let telephone = "tel://"
    let formattedString = telephone + numberString
    let url = URL(string: formattedString)!
    UIApplication.shared.open(url)
   }) {
   Text(numberString)
}
© www.soinside.com 2019 - 2024. All rights reserved.