1.autoresizingMask
view.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin
//UIViewAutoresizingNone //无
//UIViewAutoresizingFlexibleLeftMargin //到父控件的左边的距离是自适应伸缩的
//UIViewAutoresizingFlexibleRightMargin //到父控件的右边的距离是自适应伸缩的
//UIViewAutoresizingFlexibleTopMargin //到父控件的顶部的距离是自适应伸缩的
//UIViewAutoresizingFlexibleBottomMargin //到父控件的底部的距离是自适应伸缩的
//UIViewAutoresizingFlexibleWidth //宽度会跟随父控件自动伸缩
//UIViewAutoresizingFlexibleHeight //高度会跟随父控件自动伸缩
2.autoresizing与autoLayout
autoresizing只能设置自身和父控件之间的关系,仅仅能解决子控件之间的相对关系,autolayout可以解决任何控件之间的相对关系问题
autolayout的核心概念:
约束:通过给控件添加约束,来决定控件的位置和尺寸
参照:在添加约束时,是依照谁来添加
3.autolayout的警告和错误:
警告(黄色):说明控件目前的布局与约束不匹配
例:约束控件的宽度为100,而控件现在的宽度时110
错误(红色):(1) 说明缺乏必要的约束
例:只约束宽度和高度,没有约束具体的位置
或(2) 两个约束冲突
例:1个约束控件的宽度为100,另1个约束控件的宽度为110