Reputation: 2786
I'm having some difficulties understanding the difference, and when to use what.
I know the textbook definitions. I have also searched a lot regarding this very topic. Some answers here on SO were helpful to some extent, but I feel I still don't understand this properly.
Let's say I have a aCustomView.m, and when I place UI elements within that view, I use bounds, which makes sense because it's in it's own coordinate system, but, when I initialize the view using initWithFrame:
in my view-controller, should I use self.view.frame
or self.view.bounds
? Both would work, but with different results.
I really want to understand this, so any help would be appreciated.
Upvotes: 2
Views: 434
Reputation: 11537
The bounds of an UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to its own coordinate system (0,0).
The frame of an UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to the superview it is contained within.
So the difference is only a question of representation.
Upvotes: 5