Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between view's frame and view's bound + iPhone

Tags:

iphone

uiview

I want to know what is the difference between 'frame' and 'bound' property of UIView. I get the same results using both properties. I can not figure out the difference between the two..

Thanx in advance.

like image 859
tek3 Avatar asked Oct 18 '10 14:10

tek3


People also ask

What is the difference between a view's bounds and frame?

Frame refers to the coordinate system of the view's container (parent view). Bounds refer to the own coordinate system of the view.

What is a view's frame?

A view's frame specifies the view's size and its position relative to its superview. Because a view's size is always specified by its frame, a view is always a rectangle. A CGRect contains the members origin and size. The origin is a structure of type CGPoint and contains two CGFloat properties: x and y.

What is a frame in Uikit?

The frame rectangle, which describes the view's location and size in its superview's coordinate system.

What is bounds in Swift?

The bounds rectangle, which describes the view's location and size in its own coordinate system.


1 Answers

The frame is the view's location in its superview, using the superview's coordinate system.

The bounds is the view's location and size in its own coordinate system.

If you are getting the same results for both properties, it means that the view fills its superview, and both views have (0, 0) as the origin. Try changing the frame, and you will see it move to different positions within its superview.

like image 66
Kristopher Johnson Avatar answered Nov 05 '22 12:11

Kristopher Johnson