简体   繁体   English

uiimageview长宽比问题

[英]uiimageview aspectfill issue

I have layout with multiple imageviews, which look perfect with Mode->Aspect Fill as below. 我有多个图像视图的布局,如下所示通过Mode-> Aspect Fill看起来很完美。

在此处输入图片说明

now my situation is when I run the same, the whole layout just break into peaces. 现在我的处境是当我以相同的速度运行时,整个布局变得平静。

在此处输入图片说明

aspectfill is not the issue. aspectfill不是问题。 The problems is in your autolayout . 问题出在您的自动autolayout Select all your image views in storyBoard and embed them in stack view with proper constraints. 在StoryBoard中选择所有图像视图,并在适当的约束下将它们嵌入堆栈视图。

To achieve this, Select all image view then go to 为此,请选择所有图像视图,然后转到

Editor > Embed In > Stack View 编辑器>嵌入>堆栈视图

For each of your UIImageView make sure to enable clipSubviews in Interface Builder. 对于每个UIImageView ,请确保在Interface Builder中启用 clipSubviews

剪辑子视图

What happens is that your view s are positioned and sized properly, but since the contained image is bigger than the containing view it will bleed out outside of the view boundaries. 发生的情况是您的view的位置和大小正确,但是由于包含的image大于包含的视图,因此它将在视图边界之外渗出

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM