如何更改图像的大小?图像无法填充 [英] How to change image's size? Image does not fill
本文介绍了如何更改图像的大小?图像无法填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使图像四舍五入。它已经是128x128(宽度和高度),角半径是64.我想在剪切照片之前放大以拍摄照片的完整圆角尺寸。
如何缩放?
我的代码:
profileImage.layer.cornerRadius = 64
profileImage.clipsToBounds = true
我想这样做:
UIImageView 的内容模式设置为
.scaleAspectFill
。这样,图像将填满整个容器而不会扭曲它。 profileImage.contentMode = .scaleAspectFill
I'm trying to make the image rounded. It is already 128x128 (width and height) and the corner radius is 64. I want to zoom in before cutting the photo to take the full rounded size of the picture.
How to zoom it?
My code:
profileImage.layer.cornerRadius = 64
profileImage.clipsToBounds = true
I want to make it like this:
解决方案
You should set the UIImageView
's content mode to .scaleAspectFill
. That way, the image will fill up the whole container without distorting it.
profileImage.contentMode = .scaleAspectFill
这篇关于如何更改图像的大小?图像无法填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文