框架矩形与对齐矩形的区别 [英] Difference between Frame Rectangle and Alignment Rectangle

查看:154
本文介绍了框架矩形与对齐矩形的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以解释尺寸检查器框架矩形对齐矩形之间的区别是什么?

Can anyone explain what is the difference between Frame Rectangle and Alignment Rectangle in the size inspector?

推荐答案

框架描述了在屏幕上放置视图的位置以及这些视图的大小。在布局视图时,约束使用称为对齐矩形的相关几何元素。

Frames describe where to place views on the screen and how big those views will be. When laying out views, constraints use a related geometric element called an alignment rectangle.

对齐矩形基于项目内容的呈现,自动布局使用对齐矩形而不是项目的框架矩形。
通过使用对齐矩形而不是帧,自动布局可确保在布局过程中正确考虑视图边缘和中心等关键信息。
与帧不同,视图的对齐矩形应限制为核心可视元素。当新项目被绘制到视图上时,它的大小应保持不受影响。

The alignment rectangle is based on the presentation of the item’s content, Auto Layout uses the alignment rectangle instead of the item’s frame rectangle. By working with alignment rectangles instead of frames, Auto Layout ensures that key information like a view’s edges and center are properly considered during layout. Unlike frames, a view’s alignment rectangle should be limited to a core visual element. Its size should remain unaffected as new items are drawn onto the view.

考虑图-1的左侧。它显示了一个用阴影和徽章绘制的视图。在布置此视图时,您希望自动布局专注于仅对齐核心元素 - 蓝色矩形 - 而不是装饰。

Consider the left side of Figure -1. It shows a view drawn with a shadow and a badge. When laying out this view, you want Auto Layout to focus on aligning just the core element—the blue rectangle—and not the ornamentation.

图 - 1:视图的对齐矩形( center)严格指代要对齐的核心视觉元素,没有装饰。

图-1中的中心图像突出显示视图的对齐矩形。此矩形排除所有装饰,例如投影和徽章。这是您希望Auto Layout在其工作时考虑的视图的一部分。
图-1中的右边矩形包含了所有视图的可视元素。它包含阴影和徽章。如果在布局期间考虑这些装饰物,这些装饰物可能会抛弃视图的对齐特征(如中心,底部和右侧)。

The center image in Figure -1 highlights the view’s alignment rectangle. This rectangle excludes all ornamentation, such as the drop shadow and badge. It’s the part of the view you want Auto Layout to consider when it does its work. The right-hand rectangle in Figure -1 encompasses all the view’s visual elements. It encompasses the shadow and badge. These ornaments could potentially throw off a view’s alignment features (like center, bottom, and right) if they were considered during layout.

图-2自动布局仅考虑此视图的对齐矩形当把它放在超级视图的中心时。阴影和徽章不会影响其位置。

参考:链接

这篇关于框架矩形与对齐矩形的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆