TIL: Debug Trick #1

I was dealing with a little bug in which the right margins were not aligning as I wanted them to!

This was a nested view component that I did not originally write.

Debugging code that someone else has written is unavoidable and is more difficult that working with code that you yourself have written.

So, where to begin?

The background colors!

By setting each nested view to a different color, you can have an extremely visual representation of where each subview starts and ends, and what the view hierarchy is.

You can then isolate what the ‘problem’ view is, and recalibrate your constraints.

vs

Happy coding!