UIImageView with black edge

| | August 10, 2015

I have a UIButton with an image, however, the image seems to be shifted with one edge being black

enter image description here

What’s even stranger is that the edge is either side or top at what-seems-to-be random

enter image description here

The UIButton has been added via Interface Builder, and I have set the content mode to Aspect Fill. Also, in code, I have set the following:

self.itemImage.imageView.contentMode = UIViewContentModeScaleAspectFill;

Any ideas what could be the reason? Also worth noting that this happens only on a device (iPhone 6, iOS8.4). On a simulator there are no black edges, as expected.

2 Responses to “UIImageView with black edge”

  1. Try to change the background color to see if the black edges we see is the background.

    self.itemImage.imageView.backgroundColor = [UIColor yellowColor];

    If the edges didn’t become yellow, then it might be the images that cause the problem.

  2. Try this….

    self.itemImage.imageView.contentMode = UIViewContentModeCenter;

Leave a Reply