Pwn
Pwn

Reputation: 3445

why using two types (bounds/frame) to describe a view instead of one?

I'm wondering why there're two types(bounds/frame) for describing a view. Since changing a view's bounds.size.* also changes that view's frame.size.* , and vice versa, this means the only difference lies between frame and bounds is their origin, so why do we need two distinct types for describing view geometry? and by the way what does bounds.origin means exactly?

Upvotes: 1

Views: 404

Answers (1)

Dr.Kameleon
Dr.Kameleon

Reputation: 22820

Taken from CocoaDev :

  • The frame is expressed in the coordinate space of a view's superview.
  • The bounds are expressed in a view's own coordinate space.

Visual explanation (by Apple Developer Reference) :

enter image description here

Reference : http://developer.apple.com/documentation/Cocoa/Conceptual/DrawViews/Concepts/ViewHierarchy.html

Upvotes: 7

Related Questions