UIImageView Scale to fill does not clip subviews

McLawrence picture McLawrence · Aug 6, 2014 · Viewed 7.4k times · Source

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

But when I insert a bigger 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

Althoug the clipsToBounds property is set true and the View Mode is Scale to fill, the image stays in its original size.

Thanks for Your help!

Answer

AndrewK picture AndrewK · May 15, 2015

check Clip Subviews in Drawing options