I\'m developing an iOS 4 application.
I\'m using this code on an UIImageView on an UITableViewCell:
cell.photo.contentMode
Afaik, the easiest way is to calculate the imageView's frame manually from the size of the image and the frame you want it to fit in.
Create a view with the frame you're currently specifying for your imageView, make the imageView its subview. Set view.clipsToBounds = YES.
Then when you assign an image, do something like
CGFloat scaleX = view.bounds.size.width / image.size.width;
CGFloat scaleY = view.bounds.size.height / image.size.height;
CGFloat scale = MAX(scaleX, scaleY);
imageView.frame = CGRectMake(0, 0, image.size.width * scale, image.size.height * scale);
imageView.image = image;
There is no built-in way to do this, but you can do it manually:
UIGraphicsBeginImageContext(CGSizeMake(desiredWidth, desiredHeight));
[originalImage drawAtPoint...];
...
UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();