'UIImageView Clear Background on Areas Picture Doesn't Cover

I have a rotating set of pictures in my app, and some of the pictures are not the exact size or ratio for my UIImageView. I'd like to have it so that the areas of the image view that aren't taken up by the picture just stay transparent, but I'm having difficulties. Here is what I have tried so far, but it stays black on the sides around the pictures.

_imageView = [UIImageView new];
    _imageView.contentMode = UIViewContentModeScaleAspectFit;
    _imageView.backgroundColor = [UIColor clearColor];
    _imageView.opaque = NO;
    self.view.backgroundColor = [UIColor clearColor];
    [self.view addSubview:_imageView];


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source