一、autoresizing
优点:可以帮助我们完成一部分的自动布局
缺点:不能精确控制控件的位置
二、autolayout
1.添加约束
蓝色:约束正常
橙色:缺少约束
红色:约束错误
2.相对于父视图的约束
Leading Space to Container (Left) 距离父视图左边距
Trailing Space to Container (Right)距离父视图右边距
Top Space to Top layout Guide 距离父视图上边距
Bottom Space to Bottom layout Guide 距离父视图下边距
Center Horizontally in Container 距离父视图X轴中心位置
Center Vertically in Container 距离父视图Y轴中心位置
3.同等级视图之间的约束
Horizontal Spacing 视图之间X轴之间的间距
Vertical Spacing 视图之间Y轴之间的间距
Top 顶部对齐
Bottom 底部对齐
Leading 左边对齐
Trailing 右边对齐
Center X 以X轴对齐
Center Y 以Y轴对象
BaseLine 以基准线对象
equal Widths 等长
equal Heights 等高