陈斌彬的技术博客

Stay foolish,stay hungry

Xcode Frame Rectangle 和 Alignment Rectangle 的区别

img

如上图,XCode中编辑界面元素,“Size Inspector”中的 View -> Show 可以有两种选择:Frame Rectangle 和 Alignment Rectangle。

根据 http://stackoverflow.com/questions/28152533/difference-between-frame-rectangle-and-alignment-rectangle 介绍,区别大致如下:

img

一个UI元素的区域有两种:可见区域、Frame区域。以上图的button为例,一个button的可见区域就是那个左右圆角的矩形,而这个button的 Frame区域 通常情况下会比 可见区域 大,如上图,这个button的 Frame区域 可能就是在可见区域外部的一个矩形包围盒。

类似的,Frame Rectangle 指的就是外围包围盒的位置和尺寸,Alignment Rectangle 是和 UI 元素的可见区域相关的。此外,XCode 的 Auto Layout 是通过 Alignment Rectangle 而不是 Frame Rectangle 来实现的。如上图,右对齐的虚线是和这个button的可见区域的右边缘对齐的。