假设我有3个观点
A|----------|
| B|-----| |
| | C ▢ | |
| |_____| |
|__________|
如果我有一个涉及视图B和视图C的约束。
documentation建议添加到视图C是非法的:
约束必须仅涉及接收视图范围内的视图。具体而言,涉及的任何视图必须是接收视图本身或接收视图的子视图。添加到视图的约束被认为由该视图保存。评估约束时使用的坐标系是保存约束的视图的坐标系。
答案 0 :(得分:1)
修改强>
此评论来自UIView.h,上面是用于安装约束的方法:
/* A constraint is typically installed on the closest common ancestor of the views involved in the constraint.
It is required that a constraint be installed on _a_ common ancestor of every view involved. The numbers in a constraint are interpreted in the coordinate system of the view it is installed on. A view is considered to be an ancestor of itself.
*/