Venkat Venkat - 7 months ago 32
Objective-C Question

Image is not fit to the frame of UIImageView

I am creating the

using interface Builder. Its frame size is (320,67).
I want to display the image on the imageView. I am getting the image from the web. The problem is that the image get from web is stretched to display on the imageview...
Here my code

NSData *imageData=[NSData dataWithContentsOfURL:[NSURL URLWithString:@""]];
imageView.image = [UIImage imageWithData:imageData];

Can anyone tel me that how to display the image fit to display on imageView????


Either use

imageView.contentMode = UIViewContentModeScaleAspectFill;


imageView.contentMode = UIViewContentModeScaleAspectFit;

The first one will fill the frame, possibly cutting off parts of your image. The second one will show the entire image, possibly leaving areas of the frame open.