Skip to content

Instantly share code, notes, and snippets.

View farhanamustafa17's full-sized avatar

Farhana Mustafa farhanamustafa17

  • Mercury
View GitHub Profile
@harlanhaskins
harlanhaskins / View+ParentViewController.swift
Last active March 26, 2025 12:01
A SwiftUI modifier for inserting the parent UIViewController in the environment
import Foundation
import SwiftUI
extension View {
/// Adds introspection to find the parent view controller in the view hierarchy and
/// makes that view controller available to downstream views in the view hierarchy.
public func addParentViewControllerIntrospection() -> some View {
modifier(ParentViewControllerEnvironmentModifier())
}
}