How to find top visible view in SwiftUI?

191 Views Asked by At

Using this type of code we can get top visible view controller in swift. But how to check same functionality for SwiftUI.

func getTopViewController() -> UIViewController? {
var topController: UIViewController? = UIApplication.shared.keyWindow?.rootViewController
while topController?.presentedViewController != nil {
    topController = topController?.presentedViewController
}
return topController

}

0

There are 0 best solutions below