Я бы использовал
UIAlertController
с
preferredStyle: .actionSheet
, это поможет вам представить несколько вариантов пользователю, чтобы они могли выбрать, что они хотят сделать.Это будет выглядеть примерно так:
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) // makes a new UIAlertController with no title or message
// makes a new UIAlertAction to call on tap
let callAction = UIAlertAction(title: "Call", style: .default) { _ in
UIApplication.shared.open(tlfURL, options: [:], completionHandler: nil)
}
// makes a new UIAlertAction to sms on tap
let smsAction = UIAlertAction(title: "SMS", style: .default) { _ in
UIApplication.shared.open(smsURL, options: [:], completionHandler: nil)
}
// makes a new cancel action so the user can decide not to take any actions
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
// add the actions to the UIAlertController
alertController.addAction(callAction)
alertController.addAction(smsAction)
alertController.addAction(cancelAction)
// present the UIAlertController to the user so they can interact with it
present(alertController, animated: true, completion: nil)