Swift
팝업 레이아웃
khon98
2021. 2. 16. 22:03
작업할 때 슈퍼 뷰 밖으로 나가게 되는 콘텐츠들은 선택이 안됨
버튼 같은 경우 해당하는 뷰를 조금만 벗어나도 그 뷰 안에 있는 부분만 눌림
작업하는 뷰 말고 메인 뷰로 아예 빼서 작업하는 뷰와 정렬해서 작업해야 함
viewController.swift
import UIKit
class ViewController: UIViewController {
// main story board 버튼과 연결
@IBAction func showPopup(_ sender: Any) {
let storyBoard = UIStoryboard.init(name: "PopupViewController", bundle: nil)
let popupVC = storyBoard.instantiateViewController(withIdentifier: "PopupVC")
popupVC.modalPresentationStyle = .overCurrentContext
self.present(popupVC, animated: true, completion: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
}
}
cocoaTouch Class 파일
import UIKit
class PopupViewController: UIViewController {
@IBAction func PopupClose(_ sender: Any) {
self.dismiss(animated: true, completion: nil)
}
@IBAction func DoneAction(_ sender: Any) {
print("Done")
}
}