Conclusion of structure components and drawing trees

Good time of day!

Here today decided to share a few useful things I’ve worked on recently. This is mainly done to test the application, but later it was decided to issue it as a separate component. To start I will say that I used all the available information from the Internet and finalized only part of the function. Of course it is a function that allows you to view the structure vyushek that are currently on the screen of your device. This is useful for debugging to see what components are visible and which are not , and whether they have the correct dimensions.
If you try to ask Google, then you will surely find a lot of similar functions, and will not be difficult to change them for themselves, but they are limited to the console terminal structure ( tree) components. I just expanded the capabilities of the original function. In my version of the function, you can obtain a structure in the form of NSDictionary. Which subsequently can be used in your application as you please. This structure contains information about the basic parameters of components ( geometry, visible or hidden, transformation and etc.) . Naturally, this information will be relevant at the time of the function call , so you should think if you have a dynamically changing structure.

The function itself is very simple :

As you can see the function take a to parameters:

  • view – This is a view to get a structure. The function will get all subviews recursive.
  • flag – Save a extra properties (frame, bounce, alpha, clipsToBounce, etc) for views.

As a result you get a tree structure, which can be displayed in the console, or use for other purposes. For example, in order to display the tree. Now let’s talk about a component that can draw trees of structures. I wrote a component that can make a tree structure and display it as a picture. Here’s how to use it:

Permanent link to this article: