아이폰
Swift ViewController(뷰컨트롤러) 띄우기
SourceTree
2021. 11. 18. 19:50
반응형
1. 스토리보드 사용
//Storyboard ID에 이름 설정 후("MainViewController")
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let mainVC: MainViewController = storyboard.instantiateViewController(withIdentifier: "MainViewController") as! MainViewController
mainVC.arg1 = arg1//넘기는 파라미터
mainVC.modalPresentationStyle = .fullScreen//전체화면(기본은 팝업형태)
self.present(mainVC, animated: true, completion: nil)
2. Xib 사용
let vc:MainViewController = MainViewController()
vc.modalPresentationStyle = .fullScreen
vc.delegate = self
self.present(vc, animated: false, completion: nil)
3. 투명 ViewController
//띄우기
let transVC = TransViewController()
transVC.modalPresentationStyle = .overCurrentContext
self.present(transVC, animated: true, completion: nil)
//TransViewController
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor.init(red: 0, green: 0, blue: 0, alpha: 0.4)
view.isOpaque = false
//...
}
반응형