/// SwifterSwift: Helper method to present a UIViewController as a popover.
///
/// - Parameters:
/// - popoverContent: the view controller to add as a popover.
/// - sourcePoint: the point in which to anchor the popover.
/// - size: the size of the popover. Default uses the popover preferredContentSize.
/// - delegate: the popover's presentationController delegate. Default is nil.
/// - animated: Pass true to animate the presentation; otherwise, pass false.
/// - completion: The block to execute after the presentation finishes. Default is nil.
public func presentPopover(_ popoverContent: UIViewController, sourcePoint: CGPoint, size: CGSize? = nil, delegate: UIPopoverPresentationControllerDelegate? = nil, animated: Bool = true, completion: (() -> Void)? = nil) {
popoverContent.modalPresentationStyle = .popover
if let size = size {
popoverContent.preferredContentSize = size
}
if let popoverPresentationVC = popoverContent.popoverPresentationController {
popoverPresentationVC.sourceView = view
popoverPresentationVC.sourceRect = CGRect(origin: sourcePoint, size: .zero)
popoverPresentationVC.delegate = delegate
}
present(popoverContent, animated: animated, completion: completion)
}