1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Swift】モーダル遷移する、モーダルを閉じる

Posted at

これはなに

Segueを使わずにコードで NextViewController という名前のControllerへの遷移を想定する。
フルスクリーンで遷移する。

遷移

ViewController.swift
let storyboard = UIStoryboard(name: "NextViewController", bundle: nil)
let vc = storyboard.instantiateViewController(identifier: "NextViewController")

vc.modalPresentationStyle = .fullScreen

self.present(vc,animated: true)

一応

【Swift】モーダル遷移かつNavigationBarも表示させたいかつフルスクリーンで表示させたい
https://qiita.com/antk/items/e8bccccfad08a61fb140

閉じる

フルスクリーンなのでモーダルを下げる取っ手が無いためどこかに閉じるボタンを作る。

ViewController.swift
self.dismiss(animated: true, completion: nil)

おわり(´・ω・`)

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?