Come back again in this exercise you're supposed to be making 10 Baden's that they divide the screen
vertically and equally so 10 Budenz that they all have the same margin against each other and against
the top and against the bottom of the screen and they filled the entirety of your iPhone screen.
So good luck with it.
Pause the video now and if you want it to follow me along.
Give it a few seconds on and I've been to get a Southern
OK so let's go to ex-cult And you know I'm going to start a new project called Hand Baden's.
And as you can imagine the moment we hear terms such as 10 buttons or hundreds or whatever we know automatically
that we have to use something like a controller flow like your for loop or similar for me however before
I do that I want to actually make at least one body then work for me.
So I'm going to say Let my Vardhan is going to be a part of that.
And now he's asking me for a frame so I'm going to go there say Let my frame to be C. direct of the
ads asking me to give it four values and these values I didn't mention them in the last list and what
but it's now the time to talk about them.
They are C.G. floats.
They are called graphic floats and we'll talk about what color graphics is in the listen for it in a
specific.
But for now you can imagine that they're interchangeable with float values.
So I'm going to say let's Marjan to be a core graphics float and that's going to be 16 so 16 from the
left 16 from the right.
So my frame is gone and margin it's it is going to be cell of dot view dot frame or bounce whichever
you want.
In this particular case dot sized dot VAT minus and here we have to subtract two margins from it.
So Martian boy taught simply because we want to have to have it on the left we want to have the margin
and also on the right we want to have to have the margin so we have to subtract two margins from it
and the height of it.
We don't know what that's going to be.
So if we have a few challenges one of them is that we don't know what's the value for the origin and
the other one is that we don't know what's the height.
What we do know is that we want 10 of these Baden's to fit inside our view.
So how are they going to calculate my height say let height which use a CGI float to be self Dadu view
dot frame dot type.
And then from the height I have to subtract some values.
Those values are these 20 pixels I have to leave for the starting spot on top of my screen which is
essentially this little guy up there.
So 20 pixels goes forward.
There you see the battery and the time and everything else.
So toothpick says it's gone for that.
Then I'm going to have to remove one margin for the top margin and then one Bodom margin
that's another margin and then there's going to be 10 Baden's between each of them.
There's going to be another margin which makes up for nine other margins.
So nine multiplied by margin.
Or if I wanted to simplify this formula I would say 1 2 9 and that is 11.
So 20 plus 11 margins.
I didn't write it like that because I want to know where the 11 is coming from.
Otherwise it's quite simple to understand that you have 10 of these each of them will have a margin
that is 10 and you have to either one you're at the top or the bottom so 11 margins and this is the
total height.
We can spend on our models.
So we have to get this number dare and divide it by 10.
This is the sum total number we can have to spend for our Baden's right the entirety of the Hyatt minus
all the gaps.
So that's going to be a number that's number we can divide it by 10.
And that becomes the height of one single.
But it's not the copy that put it there.
So what's going to be the origin of the very first part and I'm going to say the origin of it is going
to be this fall you 20 because we have to give that for the iStock the smart plus margin whatever is
the margin up there.
You have to give these two values to.
Perfect.
Then I'm going to say my frame is obviously the frame for my balance and then I'm going to say my the
background color becomes your eye color dots say red.
So you can see it quite distinctively and then self-taught view that it's of you my body.
Let's see what you have so far.
And now we have one button up there that that Bollen has 16 pixels margin from each side.
The reason I put 16 is a variable margin because what if I want it to change that's what I want at the
gaps to be smaller.
I want it to be only three.
It could just change that into a tree.
And I read on this application and I can imagine that it's going to be a bit taller and is going to
have less gaps between them.
Now we have to run this entire thing 10 times.
So I'm going to go ahead and say we don't need to read on the margin because it only gets calculated
once.
The same thing but everybody else we have to redo it.
So I'm going to say for all I mean 0 for 10.
Here is what you want to do.
Now what do you think is going to happen if I run this code right now is going to be a 10 Baden's they're
going to put them all on top of each other.
None of them is essentially going to be lower and lower and lower as we expect them to be.
Nobody is going to come there.
And the reason is they all have the same why none of them is actually changing.
So what should we do for now.
To find out the answer we have to actually go back to our interface and ask ourselves this very question.
If this one here is at a certain location the top left there is the top left corner for the next one.
Compare the two here.
So if this is the very first block or very first button or the zero by the end of the for loop.
Now if this is here where is the next one.
Compare that with this one.
So compared to this one the next one is going to be as much as 1 the height of 1 margin.
Further down one height and one margin the next one after those is going to be another height and another
margin marginal Beloit.
There's one after that it's going to be to the heights and to the margins.
So that's right.
That in programming terms I'm going I go in here and say for the Void what ever is this value you don't
touch it then say plus which every iteration we are or he multiplied by this value the value is going
to be the height plus the margin as well.
Give us an error.
I'll take care of that in a second.
But let's understand what's happening.
We're saying that every time I get a height and a margin which is what we just discussed get a height
and a margin and add it to where the weight used to be before.
How many of those depending on where you are in the right direction of your forward not the energy you
have in here is that it's saying you cannot multiply integers if it floats.
So we have to actually get the C-g fluid value of our beach that's going to be simply you know fixing
that error.
So with that in mind go ahead and rerun this up and now we have all of these 10 Baden's.
If I change the margin to 20 that's that's perfect.
So the for loop makes a new frame each time on the body and on adds the body over there.
And then obviously the only thing that's a bit tricky is this calculation very is going to be the top
left corner of the next one.
The next one the next one the next one each time is going to be wherever the previous one was.
Plus another height and another margin and other height and other margin other high and other margin.
So on and so forth.
So that's about making 10 Baden's.
Let's move on to our next.