So well come back again.
This lesson to me is one of the most important lessons when it comes to interface design because it
teaches us how to use hard coded values to build interface items within a programming interface not
inside our interface builder.
And that's a situation that we need to do a lot of different times.
So I'm going to go to school.
I'm going to start a new project called our hard code the interface.
And I want to show you what happens when we develop an interface item here in the Interface Builder.
So there are four stages of happening.
One the you of let's say I want to make a label you find a label.
And you are located and you initialize it and then it automatically sets its size and some content and
automatically makes it a child of a certain SuperValu.
So that's right.
All of these down so that we don't forget them.
So here's the thing.
I wrote it and initialize the site about size add some attributes to a Super.
So that's essentially a process to make a new outlet.
One more time I'm going to show it to you here.
I don't care to initialize the site about the size some attributes which for instance is a label or
hello and then added to a particular Super view.
If we can do all these four steps in programming we can essentially come back to this one here but it
won't be as simple as drag and drop.
So I sort of you can sort of I'm going to go ahead and say well let my label to be AUI label.
I have two flavors.
The one I want to use is using a frame which is essentially very you want it to be.
So with a frame.
Let's see how I'm going to make a frame.
I'm going to set let my frame to be a C direct all the way is the next going to be a more familiar one
is this one x y width and height something we have done so many times before.
I'm going to say give it to me at 20 I'm 40 and 135 and a height of 44 which is very very simple.
So it's saying produce a frame of this origin.
Top left corner is 20 and 40 and a fit and height.
And of course this is the frame I want to use for my label.
I now have to add some attributes.
So I'm going to say my label dot text becomes hello hello and my label Dot thank you and color becomes
the white color.
Dark dark gray.
So now we're kind of done.
We have allocated initialized decided about the size and location.
And we have some attributes we just haven't added to anyone.
So I'm going to go ahead and say so that the you at the top view my latest So find the frame alloca
that initialized based on that frame set some properties.
And I did that to a Super view that let's this application now and see what do we get.
All right.
Now that my simulator is up we can see that our label shows up there.
It has 44 pixels high and it has 335 vet so on and so forth.
Now let's quickly talk about these values or what is X and Y and what is the V.
And height x and y is essentially a point in this space is slitted location on the top left corner.
And that could actually make it using a C.G. point.
So I quit saying let my origin be a C.G. point of the C-g point I want to use is 20 and 40.
So essentially a point in the interface is being declared the boy.
C-g point says your point is a class that helps us find different locations just like home CGI record
is the one that produces a rectangle for us that next one is this width and height.
And what that is is actually size.
So I would say my size to be C.G. size of I tells me Well give me two of these so the values are 335
and 44.
Now here's something interesting that's happening.
I got that 335 because I know they're vits of the iPhone even I'm using iPhone 8.
But what if you didn't know that I could simply say the cell phone to view that frame size dot.
So Dot is the video of the view of the entire view.
I would have 20 pixels margins from each side.
So I'm going to say minus 40.
So as simple as that you can get access to the vet and height of different objects in your view.
I know I could if I wanted to I could rewrite my frame.
I could say in a sort of CGI direct to display it would actually be a CGI act vate origin and size.
So my origin is the sky to the top left corner.
And the size is this guy my size.
So these two particular values I again I'm using the same thing.
If we run this up again nothing is going to be different is going to be exactly the same thing as it
as it was before a few minutes ago.
The only difference is now the vets of this label is dependent on the width of the screen is always
based on data.
Now what if I wanted to put this label in the center of my screen I could go on saying even after I
have to stop you I could say my labor data center which is asking for a C.G. point is C.G. point of
view.
I now I have to find out what is the center in here that would be actually quite difficult right.
I could go ahead and say Well give me this.
They put it there.
Divide it by two.
Give me the highlights and divide it by two done.
That would certainly work but a much easier way would be if I say make the center of my label to be
self do you not center.
So wherever is the center of the view a white Bangon here somewhere about where my mouse pointer is
right now.
Make my label be deaf simple as that.
Let's see if that works.
And now yes is working perfect.
So finally I want to show you one last thing when it comes to dealing with heart Kaupthing interface
items if you're of course going to do more exercises and will be using this quite often throughout this
course.
But for now the only thing I want to show you is this value self that the view frame or in the case
of or object I could actually say my labors got frame and there is another one that's caused my label
or any object that bounce.
And the difference between a boundary and frame sometimes becomes important.
I'm only going to write them down for you as a comment.
So you have that handy if you need them.
So frame includes the origin so in a frame such as this one this frame says my origin is in the case
of the self that view is 0 0.
But a boundary counts as 0 0 origin so a boundary essentially is a very good way of finding a size of
growth for finding sites because it doesn't have the origin and it doesn't understand where the object
belongs to.
So if you get the boundary of my label the boundary of it would be 0 0 and the width and height of it.
In this case 335 and 44.
Let's print both of these shall we say prints.
Our frame is and for the frame.
I'm going to say preens my label got frame and
bounce is baths and if I run this they can see it on here hopefully.
So it says frame is 20 and some number that's the origin of x and y and this is it.
And that's the height but the boundary is always 0 and 0 byte has the width and height so boundary it
depends on the object itself while frame depends on the object and vear it is being placed at.
So keep that in mind that sometimes when the origin is irrelevant for us we use the bounce when the
origin matters.
We use the phrase.
All right then.
So that was about the hard coding interface items in the next lesson we are going to do an exercise
of the.