Thursday, February 21, 2019

Use Popover style to dislay new screen



We want new screen appear as a Alert, choos style Popover for new ViewController.
let vc = second()
       
        vc.modalPresentationStyle = .Popover
        var popover = vc.popoverPresentationController   
        if let popover = vc.popoverPresentationController {       
            popover.sourceView = self.view           
            popover.sourceRect = CGRectMake(self.view.center.x,self.view.center.y+180,0,0)           
            vc.preferredContentSize = CGSizeMake(300,360)           
            popover.delegate = self
        }
       
        self.presentViewController(vc, animated: true, completion: nil)

New screen will float on current screen, width 300, height 360.

Need ajust views for new width.

No comments:

Post a Comment