Let's say you have one UIView on your screen and that's it. It's not nested in some other UIView, there are no superviews, it's there by its lonesome.
Then what does it's frame property become?
Definition of frame I found here: "A view's frame is the position of its rectangle in the superview's coordinate system."
If a view is visible, it must have a superview.
UIWindow
is also aUIView
(it derives from `UIView), so if you add it to your main window, it is still a subview of a superview.Now, if you read
UIWindow
reference:or here:
So, a
UIWindow
frame is defined in terms of the display coordinate system.And from
UIScreen
reference:Generally speaking, what is a view's frame depends on the view and how it is created. When you create a view, you normally use:
so, the view's frame is the passed
CGRect
argument, even when the view is not added to any superview.When you use
addSubview
to add that view to some other view, then the information you specified when instantiating it is used to determine the position of the added view in the superview's coordinate system.In other words, a UIView´s frame is just an attribute of the view; this attribute is interpreted as the view´s geometrical position inside of its superview when the view must be displayed.
Furthermore, a view´s frame doesn't change merely by removing it from its superview. It stays the same, in case you add it to a view again. (thanks H2CO3 for the remark)
Hope this helps.
If you have a UIView on the screen its going to at least be in the main UIWindow of your app. So the UIVIew of your first view controller will be within the main UIWindow's frame.