Recently, I spent two weeks reading the source code for navigation. I was deeply touched by its elegant syntax. It is the Apple native AutoLayout lengthy, cumbersome constraint syntax is really encapsulated concise and elegant to the extreme. Every time you look at it, you can see something different. Here you are also strongly recommended to read the source code of it. I put me in the source code during the thought of the problem, harvest, summed up in the following several questions, you see how much can answer? Feel free to comment below.

  1. MasonryWhat did you do?
[self.view addSubview:btn];
[btn makeConstrants:^(MASLayoutConstraint *make){
make.left.equalTo(self.view).offset(12);
}];
Copy the code

Does the above code have circular references, and why?

  1. What do mas_dictate, MAS_SHORTHAND_GLOBALS macros do? How does it work?

  2. Aints: What are the differences between the makeConstraints:, updateConstraints:, and remakeConstraints: that apply to those scenes?

  3. Describe the code make. Left. Right. Top. EqualTo (self. The view). Offset (0); What did you do?

  4. How would YOU like to link it elegantly?

The following questions may be more detailed, I hope you don’t mind.

  1. Why does MASViewConstraint weakly reference an instance object of MASLayoutConstraint, and what does it do with that object?

  2. MASConstraintMaker holds a Constraints array, and the MASViewConstrint class also has an array that records constraints. Both arrays record generated constraints. Is there any difference between the two arrays? What is the role of each?

- (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *))block { self.translatesAutoresizingMaskIntoConstraints  = NO; MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; constraintMaker.updateExisting = YES; block(constraintMaker);return [constraintMaker install];
}
Copy the code

MASConstraintMaker’s init method, initWithView, initializes a view attribute for MASConstraintMaker. What does MASConstraintMaker do with this view?

  1. MASConstraintMakerWhen are they initializedMASViewAttributeObjects?

I would like to invite you to discuss the essence of graceful navigation. I would like to invite you to the next article.