To create a UIPresentationController
in Swift, follow the steps below:
UIPresentationController
.main.swift89 chars4 lines
Implement the required and optional methods of UIPresentationController
protocol as per your requirements. Some of the important methods are:
presentationTransitionWillBegin()
: This method gets called when the presentation animation is about to start. Use this method to set up any views or animations required for the presentation.main.swift586 chars18 lines
dismissalTransitionWillBegin()
: This method gets called when the dismissal animation is about to start. Use this method to set up any views or animations required for the dismissal.main.swift286 chars10 lines
size(forChildContentContainer:withParentContainerSize:)
: This method is used to provide the size of the presented view controller.main.swift882 chars18 lines
Use the presentation controller in your presenting view controller.
main.swift294 chars5 lines
UIViewControllerTransitioningDelegate
protocol in your presenting view controller and implement the following methods:main.swift843 chars14 lines
That's it, you have successfully created a custom UIPresentationController
in Swift.
gistlibby LogSnag