Ejemplo n.º 1
0
        public static UIViewController GetTopViewController(this UIApplication app)
        {
            var root = app.GetTopWindow().RootViewController;
            var tabs = root as UITabBarController;

            if (tabs != null)
            {
                root = tabs.PresentedViewController ?? tabs.SelectedViewController;

                while (root.PresentedViewController != null)
                {
                    root = GetTopViewController(root.PresentedViewController);
                }

                return(root);
            }

            var nav = root as UINavigationController;

            if (nav != null)
            {
                return(nav.VisibleViewController);
            }

            while (root.PresentedViewController != null)
            {
                root = GetTopViewController(root.PresentedViewController);
            }

            return(root);
        }
Ejemplo n.º 2
0
 public static UIView GetTopView(this UIApplication app)
 {
     return(app.GetTopWindow().Subviews.Last());
 }
Ejemplo n.º 3
0
 public static UIView GetTopView(this UIApplication app) => app.GetTopWindow().Subviews.Last();