I am trying to do something that I thought would be very easy with UIView. However, I’m stuck for few days now. I think I am missing something stupid.
I have an image (let’s say 640×480) and I want to display this image in a 60×60 UIView in a tableView cell. I want to shrink the content just enough to fit the smaller dimension within the view. The larger dimension (in this case, the length) will be cropped. The new image should be something like 80×60 but only 60×60 should be visible :
(Please see here as I still can not pos images -> http://img5.imageshack.us/img5/9017/23032945.jpg)
I tried UIViewContentModeScaleToFill and UIViewContentModeScaleAspectFit but none of them are giving the result I need :
(Please see here -> http://img713.imageshack.us/img713/7673/90427118.jpg)
UIViewContentModeScaleToFill transform my 640×480 image in a 60×60 image and UIViewContentModeScaleAspectFit transform it in a 60×45 image
I don’t need to animate or pinch or slide or anything, just show the image.
As I am pretty new with iOS, a little help will be more than welcome.
How about using
UIViewContentModeScaleAspectFill? That will have the behaviour your describe if the image view has a shorter/wider aspect than your image.