0
votes

I have a UIImageView with a frame of (0, 0, 568, 300) containing a UIImage with a native size of 512x384 pixels. The contentmode is set to Aspect fit. If the user double-Taps on the view I change the size of the UIImageView with the following code:

self.imageViewerViewController.imageView.frame = CGRectMake(0, -63, 568, 426);

the result is that the right edge of the image is distorted, it does not properly scale to the new size.

Attached is an image with a black and white matrix, the distortion is on the right. It seems that the right column of pixels is repeated to the right edge of the view.

screenshot of the distortion

Can anyone help?

1

1 Answers

0
votes

I have changed the creation of the affected UIImageView from a xib file to creating it in code and using the method - (id)initWithFrame:(CGRect)aRect: with the maximum size of the scaled image for aRect. Now the image is properly scaled. Obviously the UIImageView in the xib file has been inited with a 512x384 pixel frame.