bibin-jaimon / InterviewKit-iOS

5 stars 0 forks source link

How to print subview added in the UIView #5

Open bibin-jaimon opened 11 months ago

bibin-jaimon commented 11 months ago

Print subview in the below order

<UIView...>
  <UIView...>
  <UIView...>
    <UIView...>
bibin-jaimon commented 11 months ago

The kind of issues can be solved using recursion.

func printView(rootView: UIView, spacing: String = "") {
    print("\(spacing)\(rootView.description)")
    rootView.subviews.forEach({ view in
        printView(rootView: view, spacing: spacing + "  ")
    })
}