views:

154

answers:

2

I'm trying to stretch an Image in a UIImageView - but I fail miserably :)

Following setup:

NIB-File with a view and a UIImageView attached to this view.

Wired to my class using IBOutlet UIImageView *background.

Now, in my class I try the following:

UIImage *bgImage = [[UIImage imageNamed:@"myImage.png"] stretchableImageWithLeftCapWidth:0 topCapHeight:50];
[background setImage: bgImage];

bgFrame = CGRectMake(0, 0, 250, 200);
background.frame = bgFrame;

which should stretch the image vertically - at least, that's what I thought. Alas, it's not working... :(

The image I'm using has a height of 115px (which should be enough for the stretch, I guess?)

+2  A: 

Got it... (interesting that this happens often just seconds after asking the question)

In IB, I had to set the mode in the UIImageView to «Scale to fill» and set the Autoresize-property

That's what solved the problem...

Hope that helps somebody ;)

Urs
Yes, this helped me. Thank you for posting your solution. This must just be occurring in the new iOS versions as I never experienced the issue on earlier releases. Mark it as the answer as well :)
Luke
A: 

thanks for this, just what I was looking for.

Burnsoft Ltd