2

My app load an Image in a DetailView. This Detailview is full of information, so I have to win some space. The Image i want to display is really small: 132 × 99 so i have to scale it to the whole width of the screen -> 320 x 240 this looks really big on the screen. So I want to cut the top and the bottom to get 320 x 150 without loosing aspect ratio. I tried: Scale To Fill, Scale To Fit, Center, Aspect To Fill, Aspect To Fit... in the IB. None was the right. Is there any programmatically way?

EDIT

there are some screenshots
The source:
original
Storyboard:
IB
and the ugly version:
streched
my goal (photoshopped):
enter image description here

CTSchmidt
  • 1,155
  • 3
  • 17
  • 30

1 Answers1

2

Set a necessary size to UIImageView and set it content type to UIViewContentModeScaleAspectFill

Scales the content to fill the size of the view. 
Some portion of the content may be clipped to fill the view’s bounds.

EDIT

As i understand correctly - it works fine for me, see screenshot from IB:

enter image description here

enter image description here

enter image description here It's a property of UIImageView - it's important to select Aspect Fill, not Scale To Fill

And this work only for UIImageView (not UIButtons)

Mikhail
  • 4,271
  • 3
  • 27
  • 39
  • not working. It display the image exactly like `AspectFill` in the IB. It will result in `320 x 240` and not in `320 x 150` – CTSchmidt Apr 29 '13 at 13:56
  • You should set the frame to UIImageView, not to UIImage itself / not to work with content mode. Why to use a bigger frame of UIImageView for a small and only one image? – art-divin Apr 29 '13 at 14:04
  • result: http://666kb.com/i/cdn7q7k4v2tmg7kc8.jpg it will loose every defined image size and overlay eveything. – CTSchmidt Apr 29 '13 at 14:33
  • @Curtis Timo Schmidt - it is the space around imageView... the size of UIImageView the same as the image inside – Mikhail Apr 29 '13 at 14:40
  • 3
    Also you can set property Clip Subviews = YES (also in IB) – Mikhail Apr 29 '13 at 14:46