【iOS入门】mesonry 更新约束注意点

练习UI布局

【iOS入门】mesonry 更新约束注意点_第1张图片

 

 masonry 把下划线View移动左边。

开始时对齐中间的 lable ,点击时移动到对应lable下面。

使用方法:

    [indicator mas_updateConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(curCurTab);
    }];
    

直接报错:

[LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "",
    "",
    "",
    "",
    ""
)

Will attempt to recover by breaking constraint 
0x600002860660 UILabel:0x7feeda8202e0.width == 60>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in  may also be helpful.
2020-01-13 17:08:47.697034+0800 UITabBarControllerTest[62772:3586985] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "",
    "",
    "",
    ""
)

 

原因:

参考这个https://blog.csdn.net/captainjackNO1/article/details/51275161

mas_updateConstraints方法里对同一个布局的理解就是相对的元素也是一致才行,即这里这样做才算一次update

A->B A->B的变化
A->C 是一个新的约束

 

或者 

使用:

mas_remakeConstraints 重做约束。
    [indicator mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(curCurTab);
        make.bottom.equalTo(tabLayout.mas_bottom).offset(-2);
        make.height.equalTo(@3);
        make.width.equalTo(@15);
    }];

你可能感兴趣的:(【iOS入门】mesonry 更新约束注意点)