Skip to content

Commit

Permalink
Add UIWindow+farthestPresentedViewController.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
stleamist committed Oct 29, 2023
1 parent df7db51 commit 10357f5
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#if os(iOS)

import UIKit

extension UIWindow {

/// The view controller that was presented modally on top of the window.
var farthestPresentedViewController: UIViewController? {
guard let rootViewController = rootViewController else { return nil }
return Array(sequence(first: rootViewController, next: \.presentedViewController)).last
}
}

#endif

0 comments on commit 10357f5

Please sign in to comment.