我想在电话提醒弹出窗口中添加消息。 如何制作?
答案 0 :(得分:1)
是的,你可以这样做:
func phoneCall(to phoneNumber:String) {
if let callURL:URL = URL(string: "tel:\(phoneNumber)") {
let application:UIApplication = UIApplication.shared
if (application.canOpenURL(callURL)) {
let alert = UIAlertController(title: "Your Title", message: "Do you want call that number?", preferredStyle: .alert)
let callAction = UIAlertAction(title: "Call", style: .default, handler: { (action) in
application.openURL(callURL)
})
let noAction = UIAlertAction(title: "No", style: .cancel, handler: { (action) in
print("Canceled Call")
})
alert.addAction(callAction)
alert.addAction(noAction)
self.present(alert, animated: true, completion: nil)
}
}
}