Skip to content

Instantly share code, notes, and snippets.

@raheelahmad
raheelahmad / custom-presentation.swift
Created May 14, 2019 22:16
Custom Presentation basics with UIPresentationController and friends
/// The ring leader
final class ModalTransitioningDelegate: NSObject, UIViewControllerTransitioningDelegate {
func presentationController(
forPresented presented: UIViewController,
presenting: UIViewController?,
source: UIViewController
) -> UIPresentationController? {
return PresentationController(presentedViewController: presented, presenting: presenting)
}
// Basic idea from https://swiftui-lab.com/communicating-with-the-view-tree-part-1/
import SwiftUI
// --- Provides support for a child to propogate its frame
struct ChildPreferenceData: Equatable {
let idx: Int
let bounds: CGRect
}