开发者

How to create a popup view?

How to create a pop up开发者_如何学C view programatically in xcode 4 ? I am trying to create a popup view which has a webview in it I am adding a back button in the view. I would like to go to the previous view from which it is called when the back button is pressed . How do I do that ??


use this and customize them as u needed

https://github.com/sonsongithub/PopupView


Step:1 - In storyboard create new VC, create new UIView inside VC. name it (ViewPopupUI) and then declare fields and properties you want inside ViewPopupUI.

Step:2 - Inside VC

@IBOutlet private weak var viewPopupUI:UIView!
@IBOutlet var btnClose: UIButton!

override func viewDidLoad() {
    super.viewDidLoad()

   self.showViewWithAnimation()
}

@IBAction func btnCloseAction(_ sender: Any) {

    self.hideViewWithAnimation()
}

 //MARK: - Animation Method
private func showViewWithAnimation() {

    self.view.alpha = 0
    self.viewPopupUI.transform = CGAffineTransform(scaleX: 0.1, y: 0.1)

    UIView.animate(withDuration: 0.3) {
        self.viewPopupUI.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
        self.view.alpha = 1
    }
}

private func hideViewWithAnimation() {

    UIView.animate(withDuration: 0.3, animations: {

        self.viewPopupUI.transform = CGAffineTransform(scaleX: 0.1, y: 0.1)
        self.view.alpha = 0

    }, completion: {
        (value: Bool) in

        self.removeFromParent()
        self.view.removeFromSuperview()
    })
}

Call popup

let popupVC = storyboard?.instantiateViewController(withIdentifier: "SchoolEventGoingPopup_VC") as! SchoolEventGoingPopup_VC
    popupVC.strId =  self.dictEventDetails?.object(forKey: "id") as? Int
    view.addSubview(popupVC.view)
    addChildViewController(popupVC)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜