views:

14563

answers:

4

Hi I'd like to show the image in iphone, but the image too big. I'd like to stretch it to fit the iphone screen, I can't find any class to handle it.

Any suggestion?

Thanks.

+6  A: 
UIImageView* view = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @"your_image.png"]];
view.frame = CGRectMake(0, 0, width, height);

To get the frame of the iPhone screen you can use

CGRect frame = [[UIScreen mainScreen] bounds];
Max Stewart
A: 

My ImageView was set in IB, and I would need to show multiple images, so set the image of imageView, instead of creating ImageView for individual image.

After I set the image view frame size, I am still see the same result, the image was too big, so that only part of the image was displayed on the screen.

BlueDolphin
+5  A: 

In Interface Builder, select your UIImageView. From the Tools menu, select "Attribute Inspector". In the Image View Attributes palette, select "Scale to Fill" from the Mode popup. That should scale your image to fit.

Ben Gottlieb
A: 

Cool, thanks, it works!

BlueDolphin