コード例 #1
0
        internal static T FindDescendantView <T>(this UIView view) where T : UIView
        {
            var queue = new FormsQueue <UIView>();

            queue.Enqueue(view);

            while (queue.Count > 0)
            {
                var descendantView = queue.Dequeue();

                var result = descendantView as T;
                if (result != null)
                {
                    return(result);
                }

                for (var i = 0; i < descendantView.Subviews?.Length; i++)
                {
                    queue.Enqueue(descendantView.Subviews[i]);
                }
            }

            return(null);
        }