UIImageView scale to fill does not support subsections

I am trying to add some images to my UIImageView. Everything works fine if png is the same size as ImageView.

But when I insert a larger image, it is not discarded.

This is my code:

@IBOutlet weak var PictureView: UIImageView! func loadSomePicture() { var examplePicture = UIImage(named: "Block.png") PictureView.image = exampleProfilePicture PictureView.layer.cornerRadius = 50 PictureView.clipsToBounds = true 

The Althoug property clipsToBounds is set to true, and the View mode is Scale to fill, the image remains in its original size.

Thank you for your help!

+6
source share
2 answers

I believe the problem arises because you set the contentMode to “Aspect Fill” instead of “Scale To Fill”. Can you explain a little more than what you want ImageView and Image to end up with? "Aspect Fill" will always try to keep the aspect ratio of the image when filling it to the size of the ImageView.

+3
source

check clip mobility in drawing options

+4
source

Source: https://habr.com/ru/post/973432/


All Articles