@property(nonatomic) UIEdgeInsets layoutMargins; The default spacing to use when laying out content in the view
123
typedefstructUIEdgeInsets{CGFloattop,left,bottom,right;// specify amount to inset (positive) for each of the edges. values can be negative to 'outset'}UIEdgeInsets;
这个属性类似Android中的padding,用于父View设置子View布局的内边距。
The default margins are eight points on each side.
默认值是8个点,可修改。
If the view is a view controller’s root view, the system sets and manages the margins. The top and bottom margins are set to zero points. The side margins vary depending on the current size class, but can be either 16 or 20 points. You cannot change these margins.
但如果,是ViewController的rootView,layoutMargins 是系统设置和控制的,不能修改。(文章最开始的tableView到 leading Margin 约束为 -16.就说明,left margin是16点。)
When the edge of your view is close to the edge of the superview and the preservesSuperviewLayoutMargins property is YES, the actual layout margins may be increased to prevent content from overlapping the superview’s margins.
读完感觉字面意思都懂,但就是不知道是什么意思。
preservesSuperviewLayoutMargins
@property(nonatomic) BOOL preservesSuperviewLayoutMargins; A Boolean value indicating whether the current view also respects the margins of its superview. The default value of this property is NO.
When the value of this property is YES, the superview’s margins are also considered when laying out content. This margin affects layouts where the distance between the edge of a view and its superview is smaller than the corresponding margin.
For example, you might have a content view whose frame precisely matches the bounds of its superview. When any of the superview’s margins is inside the area represented by the content view and its own margins, UIKit adjusts the content view’s layout to respect the superview’s margins. The amount of the adjustment is the smallest amount needed to ensure that content is also inside the superview’s margins.