简体   繁体   中英

Swift - Without storyboard , how do I make a modal popup?

I didn't use a storyboard and I'm having trouble finding resources on programmatically making a modal popup ( it'll be a form with white background that takes up the bottom half of the screen) after you press a button. The previous view would be disabled until you exit out of this modal popup.

Would this modal popup have its own view and view controller? How would I make the popup appear and after you exit, you give the control back to the original view controller?

Thanks?

let rateViewController = RatePopupVC()

rateViewController.modalTransitionStyle = .crossDissolve
rateViewController.modalPresentationStyle = .overCurrentContext
rateViewController.item = item // In case you want to transfer some data
self.present(rateViewController, animated: true, completion: nil)

Would this modal popup have its own view and view controller

Yes. Configure your view controller and its view, and present it with present and dismiss it with dismiss . You can add custom transition animation and custom positioning of the view.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM