Next up in the iOS fundamentals at a glance series: frames and bounds.
This is such a fundamental idea that there are a ton of articles and videos on this topic. But here’s the most basic idea…
Unlike some previous concepts, the term frame is perfect here because it’s just like a frame on a wall.
A frame (subview) is placed on the wall (superview). The frame has a location, defined by its origin in the upper-left, and a size, plus an x/y coordinate system.
Simple enough, right?
Bounds gets a little more confusing. It should probably be called “window” since it defines what part of a potentially larger view you see, but that term was already taken, so here we are with “bounds”.
Like its frame, a bounds also has its origin in the top-left, plus a size and its own x/ycoordinate system. Oddly enough, the y-axis works opposite of the frame. π€¦π»ββοΈ They do this just to make programming hard, right?
Here we can see that the frame above only showed us part of a bigger picture; what we see is defined by the bounds.
This concept is especially useful for scroll views, which essentially let you move the bounds around to look at different parts of the view.
I hope that helps. And if you ever get confused, remember a frame picture of a wall, like this one at the local coffee shop.