1 00:00:01,560 --> 00:00:08,310 Come back again in this exercise you're supposed to be making 10 Baden's that they divide the screen 2 00:00:08,370 --> 00:00:15,480 vertically and equally so 10 Budenz that they all have the same margin against each other and against 3 00:00:15,480 --> 00:00:22,060 the top and against the bottom of the screen and they filled the entirety of your iPhone screen. 4 00:00:22,090 --> 00:00:23,730 So good luck with it. 5 00:00:23,730 --> 00:00:26,510 Pause the video now and if you want it to follow me along. 6 00:00:26,750 --> 00:00:29,270 Give it a few seconds on and I've been to get a Southern 7 00:00:32,490 --> 00:00:39,930 OK so let's go to ex-cult And you know I'm going to start a new project called Hand Baden's. 8 00:00:40,140 --> 00:00:46,560 And as you can imagine the moment we hear terms such as 10 buttons or hundreds or whatever we know automatically 9 00:00:46,560 --> 00:00:54,270 that we have to use something like a controller flow like your for loop or similar for me however before 10 00:00:54,270 --> 00:00:58,310 I do that I want to actually make at least one body then work for me. 11 00:00:58,410 --> 00:01:05,170 So I'm going to say Let my Vardhan is going to be a part of that. 12 00:01:05,430 --> 00:01:14,230 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 13 00:01:14,790 --> 00:01:21,330 ads asking me to give it four values and these values I didn't mention them in the last list and what 14 00:01:21,330 --> 00:01:23,640 but it's now the time to talk about them. 15 00:01:23,670 --> 00:01:25,200 They are C.G. floats. 16 00:01:25,200 --> 00:01:31,170 They are called graphic floats and we'll talk about what color graphics is in the listen for it in a 17 00:01:31,170 --> 00:01:32,010 specific. 18 00:01:32,160 --> 00:01:37,200 But for now you can imagine that they're interchangeable with float values. 19 00:01:37,200 --> 00:01:47,550 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 20 00:01:47,550 --> 00:01:49,720 left 16 from the right. 21 00:01:49,740 --> 00:02:02,910 So my frame is gone and margin it's it is going to be cell of dot view dot frame or bounce whichever 22 00:02:02,910 --> 00:02:03,360 you want. 23 00:02:03,360 --> 00:02:13,840 In this particular case dot sized dot VAT minus and here we have to subtract two margins from it. 24 00:02:13,840 --> 00:02:21,240 So Martian boy taught simply because we want to have to have it on the left we want to have the margin 25 00:02:21,250 --> 00:02:27,560 and also on the right we want to have to have the margin so we have to subtract two margins from it 26 00:02:28,170 --> 00:02:29,290 and the height of it. 27 00:02:29,340 --> 00:02:30,840 We don't know what that's going to be. 28 00:02:30,870 --> 00:02:36,390 So if we have a few challenges one of them is that we don't know what's the value for the origin and 29 00:02:36,390 --> 00:02:38,680 the other one is that we don't know what's the height. 30 00:02:38,700 --> 00:02:45,180 What we do know is that we want 10 of these Baden's to fit inside our view. 31 00:02:45,210 --> 00:02:56,600 So how are they going to calculate my height say let height which use a CGI float to be self Dadu view 32 00:02:57,020 --> 00:03:00,800 dot frame dot type. 33 00:03:01,370 --> 00:03:04,910 And then from the height I have to subtract some values. 34 00:03:05,060 --> 00:03:12,710 Those values are these 20 pixels I have to leave for the starting spot on top of my screen which is 35 00:03:12,760 --> 00:03:15,100 essentially this little guy up there. 36 00:03:15,200 --> 00:03:16,910 So 20 pixels goes forward. 37 00:03:17,000 --> 00:03:20,220 There you see the battery and the time and everything else. 38 00:03:20,220 --> 00:03:22,430 So toothpick says it's gone for that. 39 00:03:22,730 --> 00:03:32,070 Then I'm going to have to remove one margin for the top margin and then one Bodom margin 40 00:03:34,920 --> 00:03:41,340 that's another margin and then there's going to be 10 Baden's between each of them. 41 00:03:41,350 --> 00:03:46,110 There's going to be another margin which makes up for nine other margins. 42 00:03:46,120 --> 00:03:50,230 So nine multiplied by margin. 43 00:03:50,500 --> 00:03:56,730 Or if I wanted to simplify this formula I would say 1 2 9 and that is 11. 44 00:03:56,770 --> 00:04:00,970 So 20 plus 11 margins. 45 00:04:01,110 --> 00:04:05,700 I didn't write it like that because I want to know where the 11 is coming from. 46 00:04:05,710 --> 00:04:12,580 Otherwise it's quite simple to understand that you have 10 of these each of them will have a margin 47 00:04:12,930 --> 00:04:20,290 that is 10 and you have to either one you're at the top or the bottom so 11 margins and this is the 48 00:04:20,290 --> 00:04:21,670 total height. 49 00:04:21,730 --> 00:04:24,880 We can spend on our models. 50 00:04:25,000 --> 00:04:32,510 So we have to get this number dare and divide it by 10. 51 00:04:32,540 --> 00:04:41,150 This is the sum total number we can have to spend for our Baden's right the entirety of the Hyatt minus 52 00:04:41,240 --> 00:04:42,540 all the gaps. 53 00:04:42,620 --> 00:04:47,010 So that's going to be a number that's number we can divide it by 10. 54 00:04:47,120 --> 00:04:50,710 And that becomes the height of one single. 55 00:04:51,230 --> 00:04:54,550 But it's not the copy that put it there. 56 00:04:55,130 --> 00:05:01,160 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 57 00:05:01,160 --> 00:05:10,220 to be this fall you 20 because we have to give that for the iStock the smart plus margin whatever is 58 00:05:10,220 --> 00:05:11,510 the margin up there. 59 00:05:11,570 --> 00:05:13,790 You have to give these two values to. 60 00:05:14,080 --> 00:05:15,140 Perfect. 61 00:05:15,410 --> 00:05:21,560 Then I'm going to say my frame is obviously the frame for my balance and then I'm going to say my the 62 00:05:22,410 --> 00:05:27,960 background color becomes your eye color dots say red. 63 00:05:27,980 --> 00:05:36,200 So you can see it quite distinctively and then self-taught view that it's of you my body. 64 00:05:36,680 --> 00:05:38,790 Let's see what you have so far. 65 00:05:40,490 --> 00:05:47,510 And now we have one button up there that that Bollen has 16 pixels margin from each side. 66 00:05:47,520 --> 00:05:54,510 The reason I put 16 is a variable margin because what if I want it to change that's what I want at the 67 00:05:54,510 --> 00:05:56,940 gaps to be smaller. 68 00:05:57,060 --> 00:05:58,570 I want it to be only three. 69 00:05:58,690 --> 00:06:00,540 It could just change that into a tree. 70 00:06:00,860 --> 00:06:06,210 And I read on this application and I can imagine that it's going to be a bit taller and is going to 71 00:06:06,210 --> 00:06:08,980 have less gaps between them. 72 00:06:09,000 --> 00:06:13,180 Now we have to run this entire thing 10 times. 73 00:06:13,290 --> 00:06:19,440 So I'm going to go ahead and say we don't need to read on the margin because it only gets calculated 74 00:06:19,470 --> 00:06:20,830 once. 75 00:06:20,940 --> 00:06:24,980 The same thing but everybody else we have to redo it. 76 00:06:24,990 --> 00:06:31,810 So I'm going to say for all I mean 0 for 10. 77 00:06:32,040 --> 00:06:34,310 Here is what you want to do. 78 00:06:34,320 --> 00:06:40,760 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 79 00:06:40,770 --> 00:06:43,010 going to put them all on top of each other. 80 00:06:43,230 --> 00:06:49,410 None of them is essentially going to be lower and lower and lower as we expect them to be. 81 00:06:49,410 --> 00:06:50,940 Nobody is going to come there. 82 00:06:51,150 --> 00:06:55,980 And the reason is they all have the same why none of them is actually changing. 83 00:06:55,980 --> 00:06:57,670 So what should we do for now. 84 00:06:57,940 --> 00:07:04,020 To find out the answer we have to actually go back to our interface and ask ourselves this very question. 85 00:07:04,410 --> 00:07:12,240 If this one here is at a certain location the top left there is the top left corner for the next one. 86 00:07:12,240 --> 00:07:14,280 Compare the two here. 87 00:07:14,520 --> 00:07:22,230 So if this is the very first block or very first button or the zero by the end of the for loop. 88 00:07:22,230 --> 00:07:25,230 Now if this is here where is the next one. 89 00:07:25,230 --> 00:07:27,320 Compare that with this one. 90 00:07:27,330 --> 00:07:34,380 So compared to this one the next one is going to be as much as 1 the height of 1 margin. 91 00:07:34,380 --> 00:07:42,180 Further down one height and one margin the next one after those is going to be another height and another 92 00:07:42,180 --> 00:07:43,410 margin marginal Beloit. 93 00:07:43,590 --> 00:07:47,340 There's one after that it's going to be to the heights and to the margins. 94 00:07:47,490 --> 00:07:48,240 So that's right. 95 00:07:48,240 --> 00:07:54,480 That in programming terms I'm going I go in here and say for the Void what ever is this value you don't 96 00:07:54,480 --> 00:08:04,920 touch it then say plus which every iteration we are or he multiplied by this value the value is going 97 00:08:04,920 --> 00:08:09,590 to be the height plus the margin as well. 98 00:08:09,590 --> 00:08:10,410 Give us an error. 99 00:08:10,410 --> 00:08:11,880 I'll take care of that in a second. 100 00:08:11,880 --> 00:08:13,530 But let's understand what's happening. 101 00:08:13,540 --> 00:08:21,460 We're saying that every time I get a height and a margin which is what we just discussed get a height 102 00:08:22,340 --> 00:08:27,580 and a margin and add it to where the weight used to be before. 103 00:08:27,660 --> 00:08:33,600 How many of those depending on where you are in the right direction of your forward not the energy you 104 00:08:33,600 --> 00:08:38,820 have in here is that it's saying you cannot multiply integers if it floats. 105 00:08:38,820 --> 00:08:45,930 So we have to actually get the C-g fluid value of our beach that's going to be simply you know fixing 106 00:08:45,930 --> 00:08:46,950 that error. 107 00:08:46,950 --> 00:08:54,250 So with that in mind go ahead and rerun this up and now we have all of these 10 Baden's. 108 00:08:54,350 --> 00:09:00,380 If I change the margin to 20 that's that's perfect. 109 00:09:00,380 --> 00:09:07,370 So the for loop makes a new frame each time on the body and on adds the body over there. 110 00:09:07,610 --> 00:09:13,940 And then obviously the only thing that's a bit tricky is this calculation very is going to be the top 111 00:09:13,940 --> 00:09:16,520 left corner of the next one. 112 00:09:16,520 --> 00:09:22,970 The next one the next one the next one each time is going to be wherever the previous one was. 113 00:09:23,090 --> 00:09:29,620 Plus another height and another margin and other height and other margin other high and other margin. 114 00:09:29,780 --> 00:09:31,170 So on and so forth. 115 00:09:31,580 --> 00:09:34,820 So that's about making 10 Baden's. 116 00:09:34,970 --> 00:09:35,890 Let's move on to our next.