天天看點

autolayout - sizeClass 學習 ~ two

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所示,它表示了一個被繪制成陰影和徽章的