如何更改图像大小?图像未填充
How to change image's size? Image does not fill
我正在尝试使图像变圆。已经是128x128(宽高),圆角半径为64,我想在切图前先放大,拍出完整的圆角尺寸
如何缩放?
我的代码:
profileImage.layer.cornerRadius = 64
profileImage.clipsToBounds = true
我想做成这样:
请首先确保您的图片高度和宽度必须相等。和约束设置正确
之后更改为行
profileImage.layer.cornerRadius = profileImage.frame.size.width/2
profileImage.clipsToBounds = true
您应该将 UIImageView
的内容模式设置为 .scaleAspectFill
。这样,图像将填满整个容器而不会扭曲它。
profileImage.contentMode = .scaleAspectFill
我正在尝试使图像变圆。已经是128x128(宽高),圆角半径为64,我想在切图前先放大,拍出完整的圆角尺寸
如何缩放?
我的代码:
profileImage.layer.cornerRadius = 64
profileImage.clipsToBounds = true
我想做成这样:
请首先确保您的图片高度和宽度必须相等。和约束设置正确
之后更改为行
profileImage.layer.cornerRadius = profileImage.frame.size.width/2
profileImage.clipsToBounds = true
您应该将 UIImageView
的内容模式设置为 .scaleAspectFill
。这样,图像将填满整个容器而不会扭曲它。
profileImage.contentMode = .scaleAspectFill