问题
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:
回答1:
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
回答2:
please first ensure your image height and width must be equal. and constraint set properly
after that change below to line
profileImage.layer.cornerRadius = profileImage.frame.size.width/2
profileImage.clipsToBounds = true
来源:https://stackoverflow.com/questions/45919697/how-to-change-images-size-image-does-not-fill