Bummer! This is just a preview. You need to be signed in with a Treehouse account to view the entire video.
Anatomy of a UIView1:16 with Amit Bijlani
A UIView is a rectangular area displayed on the screen. Like every other class a UIView has several properties and methods, one of which known as subviews. The subviews property is an array that has views or controls added to the UIView.
[Build a Simple iPhone App with Amit Bijlani] [Understanding View and ViewControllers Project]
In the previous stage we added a Label and a Button to our View.
It was as easy as dragging and dropping these Controls on a View.
But what is a View, and how does this all work?
Every Control or View that you see on the screen is driven by a Class.
It is an instance of a Class that contains behavior and attributes or rather methods and properties.
When we launch our app, we see a nicely assembled View which seems seamless.
Every app has a Window and when the app launches, the main ViewController attaches a View to this Window.
In most cases you will never have to interact with the Window, but it's good to know how it works.
Each ViewController has a View which belongs to a Class called UIView.
And a UIView contains several properties, one of which is an NSArray called Subviews.
Each time you add a Control such as Label, Button, Switch, Slider,
or any other such Control it is added to the Array of Subviews.
The Controls are also stacked in the order which they are added.
You need to sign up for Treehouse in order to download course files.Sign up