autolayout - sizeClass 学习 ~ two

来源:互联网 发布:vscode golang 格式化 编辑:程序博客网 时间:2024/06/05 07:56

Alignment Rectangles: 这个概念在autoLayout中非常常见,所以特开一贴


Image Embellishments

When you include embellishments in your pictures such as shadows, sparkles, badges, and other items that extend beyond the image’s core content, an image’s natural size may no longer reflect the way you want Auto Layout to handle layout. In Auto Layout, constraints determine view size and placement, using a geometric element called an alignment rectangle. The UIKit API calls help you control that placement.

图像点缀

当你修饰你的相片例如阴影,闪耀效果,徽章和其他项目这超过了图片的核心内容。一个图像的原始大小可能不会反映出你想利用自动布局去处理的方式。在自动布局中,约束决定了视图的大小和布局,利用了称为-alignment rectangle 的几何元素。UIKit API调用帮你控制布局。

Alignment Rectangles

As developers create complex views, they may introduce visual ornamentation such as shadows, exterior highlights, reflections, and engraving lines. As they do, these features are often drawn onto image art rather than being added through layers or subviews. 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. Consider the left side of Figure 1-11. 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.

Alignment Rectangles

作为开发者创建复杂的视图,他们可能引进了可视化的修饰例如阴影,外部的亮彩,反射,雕刻线。当他们做的时候,这些功能往往绘制到影像艺术,而不是通过图层或子视图添加,不像Frames,一个视图的 alignment rectangle 应该被限制到一个核心的可视化元素。他们的大小应该不会因为新的项目元素被添加到视图而受到影响。如左图1-11所示,它表示了一个被绘制成阴影和徽章的

0 0