Ios – Image is not fit to the frame of UIImageView

iosipadiphoneobjective cuiimageview

I am creating the UIImageView 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:@"http://www.isco.com/webproductimages/appBnr/bnr1.jpg"]];
imageView.image = [UIImage imageWithData:imageData];

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

Best Answer

Either use

imageView.contentMode = UIViewContentModeScaleAspectFill;

or

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.