简体   繁体   English

UIImageVIew根据ImageView大小裁剪图像中心

[英]UIImageVIew crop Image center according to ImageView size

I'm trying to create a UIImageView that will have a fixed size (i'm not using auto layout) and content image inside it will be centred. 我正在尝试创建一个具有固定大小的UIImageView(我没有使用自动布局),并且其中的内容图像将居中。

The problem is that the image is big, and it enlarge my UIImageView - which corrupt the view i'm showing, so my only option is to Scale To Fit which make my image look bad. 问题是图像很大,并且放大了我的UIImageView-破坏了我正在显示的视图,所以我唯一的选择是“缩放以适合”,这会使我的图像看起来很糟糕。

Is it possible to do that with AutoLayout ? 是否可以使用AutoLayout做到这一点?

AHHH - just use "center" mode on that selector. AHHH-只需在该选择器上使用“居中”模式即可。

And set CLIP SUBVIEWS checkbox. 并设置CLIP SUBVIEWS复选框。

Let us know if that fixes it. 让我们知道是否可以解决问题。


For 2015 onwards, it's worth noting that there is no reason at all not to use autolayout. 从2015年开始,值得注意的是,根本没有理由不使用自动版式。

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

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