Bounds Vs Frames

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.

Note: The width and the height of the view is the same regardless of whether we are looking at the bounds or frame.

What is different is the x,y positioning of the view. In the case of the bounds, the x and y coordinates are at 0,0 as these coordinates are relative to the view itself. However, the frame x and y coordinates are relative to the position of the view within the parent view.

View-related Structures
• CGPoint
      location in space: x and y components
  ■

• CGSize
      dimensions of something...
View-related Structure

Creation Function           Example

                            CGPoint point = CGPointMake (100....
UIView Coordinate System
  Origin in upper left corner
■

■ y axis grows downwards

                                0, 0...
Location and Size
• View’s location and size expressed in two ways
         Frame is in terms of superview’s coordinate sy...
Frame and Bounds
• Which to use?
      Usually depends on the context
  ■

• If you are using a view, typically you use f...
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s