UIAlertController ব্যবহার করে কাস্টম ডায়লগ বক্স তৈরি করুন।
func createAlert(withTitle title: String, andDescription description: String) {
let alert = UIAlertController(title: title, message: description, preferredStyle: .alert)
let okAction = UIAlertAction(title: "Ok", style: .default) { _ in
print("You tapped ok")
// custom action here
}
alert.addAction(okAction)
self.present(alert, animated: true, completion: nil)
}
override func viewWillLayoutSubviews() {
self.createAlert(withTitle: "This is an alert", andDescription: "Enter your description here.")
}
ফলাফল —
