ios - Swift 4: 使用 UIAlertController

LongOld

2018-03-08T09:03:28Z||2018-03-08T09:03:28Z

之前写过一个ios 8的UIAlertController,现在改成swift 4的版本:

let alertController = UIAlertController(title: "title", message: "message", preferredStyle: .alert)

alertController.addAction(UIAlertAction(title: TXT("button_ok"), style: .default, handler: { (action) in
    // handle ok click
}))

alertController.addAction(UIAlertAction(title: TXT("button_cancel"), style: .default, handler: { (action) in
    // handle cancel click
}))

// self本身是UIViewController
present(alertController, animated: true, completion: nil)