View a 与 View b 是属于同一层级的两个 View,View b 的位置可以由 View a 决定。
注意:如果 a 与 b 不是属于同一层级,调用以下方法将报错。
- leftTo()
View b 的左边与 View a 的距离是 n
b.petralRestraint.leftTo(a, offset: n)
- rightTo()
View b 的右边与 View a 的距离是 n
b.petralRestraint.rightTo(a, offset: n)
- topTo()
View b 的顶部与 View a 的距离是 n
b.petralRestraint.topTo(a, offset: n)
- bottomTo()
View b 的底部与 View a 的距离是 n
b.petralRestraint.bottomTo(a, offset: n)
- leftAs
View b 的左边与 View a 的左边的水平位置一致(可偏离 n)
b.petralRestraint.leftAs(a, offset: n)
- rightAs
View b 的右边与 View a 的右边的水平位置一致(可偏离 n)
b.petralRestraint.rightAs(a, offset: n)
- topAs
View b 的顶部与 View a 的顶部的水平位置一致(可偏离 n)
b.petralRestraint.topAs(a, offset: n)
- bottomAs
View b 的底部与 View a 的底部的水平位置一致(可偏离 n)
b.petralRestraint.bottomAs(a, offset: n)
- xCenterAs
b.petralRestraint.xCenterAs(a, offset: n)
View b 的中间水平位置与 View a 的中间水平位置一致(可偏离 n)
- yCenterAs
b.petralRestraint.yCenterAs(a, offset: n)
View b 的中间垂直位置与 View a 的中间垂直位置一致(可偏离 n)
- centerAs
b.petralRestraint.centerAs(a, xOffset: m, yOffset: n)
View b 的中间点与 View a 的中间点位置一致(x 可偏离 m,y 可偏离 n)
View a 与 View b 的父 View,View b 的位置可以由 View a 决定。
注意:如果 a 不是 b 的父 View,调用以下方法将报错。
- leftIn()
View b 的左边与父 View 的左边的距离为 n
b.petralRestraint.leftIn(offset: n)
- rightIn()
View b 的右边与父 View 的 y 右边的距离为 n
b.petralRestraint.rightIn(offset: n)
- topIn()
View b 的顶部与父 View 的顶部的距离为 n
b.petralRestraint.topIn(offset: n)
- bottomIn()
View b 的底部与父 View 的底部的距离为 n
b.petralRestraint.bottomIn(offset: n)
- xCenterIn()
View b 的水平位置位于父 View 的中间
b.petralRestraint.xCenterIn()
- yCenterIn()
View b 的垂直位置位于父 View 的中间
b.petralRestraint.yCenterIn()
- centerIn()
View b 的水平和垂直位置位于父 View 的中间
b.petralRestraint.centerIn()
- width()
View b 的固定宽度为 n
b.petralRestraint.width(n)
- height()
View b 的固定高度为 n
b.petralRestraint.height(n)