我正在尝试创建自定义AlertView,并在应用打开后立即弹出主屏幕。在故事板上使用自定义XIB或View Controller。我已经阅读了UIKit,以找到一种将基本警报视图切换为我要呈现的自定义视图的方法,但是仍然没有骰子。
这里是我要替换基本AlertView Custom Alert的自定义Xibs>
我的代码当前在主屏幕打开时显示AlertView,我只是不知道如何将基本警报视图切换到自定义视图
import UIKit class HomeViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() } override func viewDidAppear(_ animated: Bool) { createAlert(title: "Are you 21 years of Age or Over?", message: "") } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } func createAlert (title: String, message: String) { let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.actionSheet) // CREATING ON BUTTON alert.addAction(UIAlertAction(title: "Yes", style: UIAlertAction.Style.default, handler: { (action) in alert.dismiss(animated: true, completion: nil) print("Yes") })) alert.addAction(UIAlertAction(title: "No", style: UIAlertAction.Style.default, handler: { (action) in alert.dismiss(animated: true, completion: nil) print("No") })) self.present(alert, animated: true, completion: nil) }
}
我正在尝试创建自定义AlertView,并在应用打开后立即弹出主屏幕。在故事板上使用自定义XIB或View Controller。我已经阅读了UIKit,找到了一种切换方法...