Iphone – UIImageView change Width and Height


I've read various posts on here asking similar questions… I've tried various ways that were posted including bounds and frames etc. including the following:

myImage.frame = CGRectMake(0.0f, 0.0f,50.0f, 50.0f);


myImage.bounds = CGRectMake(0.0f, 0.0f,50.0f, 120.0f);

neither of those work.

However, I find it interesting that the following code let's me move the Image around but doesn't change the width:

CGRect frameRect = myImage.frame;
frameRect.size.width = 50.0f;
frameRect.origin.x += 10.5f;
myImage.frame = frameRect;

So why don't any of these change the width/height of my ImageView?

I found another post on here that basically states I have to right a small book of code to get it resize my image… is that true?

Such as this one:
UIImage: Resize, then Crop

certainly this is simpler than that??

Best Solution

The following will change the size of the UIImaveView, clipping the underlying image without resizing it and keeping it aligned to bottom left of view:

imageView.frame = CGRectMake(
             imageView.frame.origin.y, newWidth, newHeight);

imageView.contentMode = UIViewContentModeBottomLeft; // This determines position of image
imageView.clipsToBounds = YES;
Related Question