1 00:00:00,370 --> 00:00:03,540 Once you've identified the kinds of attributes you want to use, 2 00:00:03,540 --> 00:00:07,280 the next step is to build a relationship between the attributes. 3 00:00:07,280 --> 00:00:09,920 There are three kinds of relationships we can build. 4 00:00:09,920 --> 00:00:14,450 And so far in our courses, we've only used one, an equal relation. 5 00:00:14,450 --> 00:00:17,659 An equal relation is very intuitive, and simply says, 6 00:00:17,659 --> 00:00:22,410 I want ViewB's height attribute to equal ViewA's height attribute. 7 00:00:22,410 --> 00:00:26,435 There are two more kinds of relationships we can establish between attributes, 8 00:00:26,435 --> 00:00:31,410 a less than or equal and a greater than or equal. 9 00:00:31,410 --> 00:00:36,580 As the title states, when you specify a less than or equal relationship, 10 00:00:36,580 --> 00:00:40,750 you're saying that I want ViewB's width attribute to be less than or 11 00:00:40,750 --> 00:00:44,110 equal to ViewA's width attribute by a certain amount. 12 00:00:44,110 --> 00:00:47,420 We can do the opposite with the greater than or equal relation, and 13 00:00:47,420 --> 00:00:50,710 these two are known as inequality constraints. 14 00:00:50,710 --> 00:00:54,200 Once we've established the type of relationship we want to create, 15 00:00:54,200 --> 00:00:56,680 the next part is the multiplier. 16 00:00:56,680 --> 00:01:01,100 The multiplier is a fixed value that lets you adjust the relationship between 17 00:01:01,100 --> 00:01:03,620 the two attributes by a certain factor. 18 00:01:03,620 --> 00:01:08,386 For example, you can say that you want ViewB's height to be equal to 0.75 times, 19 00:01:08,386 --> 00:01:10,849 or two-thirds that of ViewA's height. 20 00:01:12,060 --> 00:01:14,840 The 0.75 value here is the multiplier. 21 00:01:14,840 --> 00:01:16,740 The multiplier is a required value and 22 00:01:16,740 --> 00:01:21,240 often times the value provided is simply one to keep the relationships equal. 23 00:01:21,240 --> 00:01:23,930 But the multiplier is really powerful because you can use 24 00:01:23,930 --> 00:01:27,030 any floating point number to build that relationship. 25 00:01:27,030 --> 00:01:29,800 It is important to know that the multiplier cannot be changed 26 00:01:29,800 --> 00:01:32,200 after you've created the constraint equation. 27 00:01:32,200 --> 00:01:34,270 If you want to modify the multiplier, 28 00:01:34,270 --> 00:01:39,200 you essentially need to get rid of the constraint, and create a new one entirely. 29 00:01:39,200 --> 00:01:41,410 So let's go back to the constraint equation. 30 00:01:41,410 --> 00:01:44,440 We now know what attributes are available to us to use, 31 00:01:44,440 --> 00:01:46,810 as well as what the multiplier does. 32 00:01:46,810 --> 00:01:49,240 So the last bit remaining is the constant. 33 00:01:49,240 --> 00:01:53,590 The constant is quite easy to understand and allows us to offset a view 34 00:01:53,590 --> 00:01:57,420 from any desired attribute by a certain floating point value. 35 00:01:57,420 --> 00:02:01,080 In our very first example, we said we wanted to position a label away from 36 00:02:01,080 --> 00:02:04,750 the bottom of the superview by a certain amount of padding. 37 00:02:04,750 --> 00:02:07,550 That padding is this constant value. 38 00:02:07,550 --> 00:02:11,330 A second ago, we mentioned that there were three types of relationships we could set 39 00:02:11,330 --> 00:02:15,690 up, equal, greater than or equal, and less than or equal. 40 00:02:15,690 --> 00:02:19,520 When we implement the inequality constraints, we use the constant value to 41 00:02:19,520 --> 00:02:23,300 specify the number we want to be greater than or equal to. 42 00:02:23,300 --> 00:02:25,580 Funnily enough, as I mentioned earlier, 43 00:02:25,580 --> 00:02:29,700 the constant in this constraint equation is not actually constant. 44 00:02:29,700 --> 00:02:30,920 While the attributes and 45 00:02:30,920 --> 00:02:35,910 multiplier are fixed when you create the constant, you can modify the constant bit 46 00:02:35,910 --> 00:02:39,240 of the constraint at any point to adjust the offset. 47 00:02:39,240 --> 00:02:43,100 Constant here implies that it is a constant offset away, 48 00:02:43,100 --> 00:02:45,570 rather than a value that is unchanging. 49 00:02:45,570 --> 00:02:49,680 Okay, let's use this knowledge to build up a few examples over the next few videos.