아주 간단한 기본 팝업 창!
작은 팝업창이 그 위에 따로 뜨는게 아니라
그냥 아예 팝업화면페이지를 만들어서 휘리릭 화면 전환을 하는 간단한 눈속임(?)방식입니다!
첫번째 viewcontroller: 누르면 팝업이 튀어나올 버튼 하나 만들어 줍니다.

버튼 작동 함수만 작성해주면 됩니다.
@IBAction func POPUPView(_ sender: Any) {
//내비게이션을 이용한 화면 전환
let storyboard = UIStoryboard.init(name: "POPUP", bundle: nil)
let alertPopupVC = storyboard.instantiateViewController(withIdentifier: "PopupVC") as! POPUP
alertPopupVC.modalPresentationStyle = .overCurrentContext
alertPopupVC.modalTransitionStyle = .crossDissolve
self.present(alertPopupVC, animated: true, completion: nil)
}
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var POPButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func POPUPView(_ sender: Any) {
let storyboard = UIStoryboard.init(name: "POPUP", bundle: nil)
let alertPopupVC = storyboard.instantiateViewController(withIdentifier: "PopupVC") as! POPUP
alertPopupVC.modalPresentationStyle = .overCurrentContext
alertPopupVC.modalTransitionStyle = .crossDissolve
self.present(alertPopupVC, animated: true, completion: nil)
}
}
두번째 viewcontroller는 (눈속임)팝업 화면을 만들거에요.

얘도 버튼만 해주면 됩니다!
@IBAction func ClosePopup(_ sender: Any) {
//돌아가는 버튼
self.dismiss(animated: true, completion: nil)
}
import UIKit
class POPUP: UIViewController {
@IBOutlet weak var BackButton: UIButton!
@IBOutlet weak var PopupLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func ClosePopup(_ sender: Any) {
self.dismiss(animated: true, completion: nil)
}
}
아직 많이 부족해서 이런 눈속임 팝업만 사용합니다...ㅎㅎ
'IOS' 카테고리의 다른 글
| IOS] Kingfishur 사용법 코드 (0) | 2023.11.07 |
|---|---|
| IOS] ViewController간 정보 보내기 (0) | 2023.10.26 |
| IOS] FrameWork 추가 및 수정하는 방법 (0) | 2023.10.24 |
| IOS] storyboard SCROLLVIEW 구현 및 수정 방법 (0) | 2023.10.24 |
| IOS] COCOAPODS 코코아팟 사용법/POD 추가&수정&만들기 (0) | 2023.10.24 |