ボタンを押した時に下から出てくるやつを表示するコード


ViewController.swift
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
private func popUp() {
let alertController = UIAlertController(title: "確認", message: "本当に実行しますか", preferredStyle: .actionSheet)
let yesAction = UIAlertAction(title: "はい", style: .default, handler: nil)
alertController.addAction(yesAction)
let noAction = UIAlertAction(title: "いいえ", style: .default, handler: nil)
alertController.addAction(noAction)
let cancelAction = UIAlertAction(title: "キャンセル", style: .cancel, handler: nil)
alertController.addAction(cancelAction)
present(alertController, animated: true, completion: nil)
}
@IBAction func doButtonTap(_ sender: Any) {
popUp()
}
}
豆知識
comd + shift + l(エル)
でlibraryを表示できる。