如何更改图像的大小?图片没有填写

时间:2017-08-28 13:00:11

标签: swift image profile

我正在尝试使图像四舍五入。它已经是128x128(宽度和高度),角半径是64.我想在剪切照片之前放大以拍摄照片的完整圆角尺寸。

Example

如何缩放?

我的代码:

profileImage.layer.cornerRadius = 64
profileImage.clipsToBounds = true

我想这样做:

Borders are rounded here

2 个答案:

答案 0 :(得分:0)

请首先确保您的图像高度和宽度必须相等。和约束设置正确

在下面更改为行

之后
profileImage.layer.cornerRadius = profileImage.frame.size.width/2
profileImage.clipsToBounds = true

答案 1 :(得分:0)

您应该将UIImageView的内容模式设置为.scaleAspectFill。这样,图像将填满整个容器而不会扭曲它。

profileImage.contentMode = .scaleAspectFill
相关问题