【Xcode/Swift】親Viewに重ねてPopupViewを表示する

実装 (View側)

HomeViewController.storyboard (親View)

CrossDissolveViewController.storyboard (Popupで表示するView)

実装 (ViewController側)

HomeViewController.swift

import UIKit

final class HomeViewController: UIViewController {
    // MARK: - Properties
    @IBOutlet private weak var showPopupViewButton: DesignableButton!

    // MARK: - View Life Cycle
    override func viewDidLoad() {
        super.viewDidLoad()
    }

    @IBAction func showPopupAction(_ sender: Any) {
        let controller = CrossDissolveViewController()
        controller.modalPresentationStyle = .overFullScreen
        controller.modalTransitionStyle = .crossDissolve
        self?.present(controller, animated: true)
    }
}

CrossDissolveViewController.swift

import UIKit

final class CrossDissolveViewController: UIViewController {
    // MARK: - Properties
    @IBOutlet private weak var closeButton: DesignableButton!

    // MARK: - View Life Cycle
    override func viewDidLoad() {
        super.viewDidLoad()
    }

    @IBAction func closeAction(_ sender: Any) {
        self.dismiss(animated: true)
    }

}

この記事は役に立ちましたか?

はい
いいえ
貴重なフィードバックありがとうございます!