Masonry约束崩溃

时间:2022-06-24 12:29:51

报错:

Trapped uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:]: A constraint cannot be made between a leading/trailing attribute and a right/left attribute. Use leading/trailing for both or neither.'

堆栈信息:

Masonry约束崩溃

原因:你在制定约束时,约束的对象和参考对象没有使用同一约束的成员属性,如下:

Masonry约束崩溃

前面使用leading那么后者也要用leading,保持前后一致就好。