Aucune description

AlertController.swift 1.3KB

    // // AlertController.swift // PaiAi // // Created by FFIB on 2017/11/21. // Copyright © 2017年 yb. All rights reserved. // import UIKit class AlertController: UIViewController { override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) commonInit() } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) commonInit() } private func commonInit() { self.modalPresentationStyle = .custom } override func viewDidLoad() { super.viewDidLoad() let tap = UITapGestureRecognizer(target: self, action: #selector(disappear)) tap.delegate = self view.addGestureRecognizer(tap) } @objc func disappear() { dismiss(animated: true, completion: nil) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } } extension AlertController: UIGestureRecognizerDelegate { public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool { if touch.view == view { return true } return false } }