[英]Adjust UIImage with Aspect Ratio using Autolayout
Is it possible to automatically resize uiimage based on autolayout with aspect ratio (1:1)? 是否可以根据具有宽高比(1:1)的自动布局来自动调整uiimage的大小?
Btw I'm using collectionview as my view. 顺便说一句,我正在使用collectionview作为我的视图。
Here's my layout in storyboard 这是我在情节提要中的布局
and here's the result when running the app 这是运行应用程序时的结果
If you want to have the UIImageView
to always be a square and set the an aspect ratio on the width and height. 如果要使
UIImageView
始终为正方形,并在宽度和高度上设置纵横比。
However if you want to resize the UIImage
depending on the size of the imageView then in your custom UICollectionViewCell
make the necessary adjustments in the layoutSubviews()
. 但是,如果要根据
UICollectionViewCell
的大小调整UIImage
的大小,则在自定义UICollectionViewCell
中对layoutSubviews()
进行必要的调整。 Here you can inspect the size of the UIImageView
在这里您可以检查
UIImageView
的大小
. 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.