1

I have an issue with UIImageView in UITabelViewCell.

here is my UIImageView in the interface builder and it's constraints

enter image description here

When i set the mode "scale to fill" i got this result (which match the constraints and my expectations)

enter image description here but I don't want that mode!!

What I want is "Aspect Fill", but sitting this mode give me this result

enter image description here

How Can I handle this issue ?

Community
  • 1
  • 1
OXXY
  • 1,047
  • 2
  • 18
  • 43

3 Answers3

7

Using aspect fill keeps the proportions but may result in the image being drawn outside the bounds of the view. You need to clip the subviews on the image view (you can see this option in the interface builder screenshots above) and then the excess parts of the image will not be drawn.

If you want to keep proportions and also see the entire image, then you need Aspect Fit, but this will result in blank areas to the sides of the image if it doesn't match the aspect ratio of the view.

jrturton
  • 118,105
  • 32
  • 252
  • 268
0

There is a constrains mismatch for your UIImageView,

Use below constrains only,

Top Space -> ContentView

Bottom Space -> ContentView

Trailing Space -> ContentView

Leading Space -> Only One Label

or

Top Space -> ContentView

Height -> 161

Leading Space -> Only One Label

Width -> 151
DilumN
  • 2,889
  • 6
  • 30
  • 44
  • Thank you so much but can't go with this solution since i need to set the labels width and this is not what i want. i want the image to capture a specific width and the reaming width go for the labels – OXXY Apr 30 '15 at 10:24
0

While selecting the content mode to Aspect Fill for the image view, the content is getting out of the bounds of the image view. This is because in aspect fill mode the content is filled till the time the bounds of the container (image view) are fully filled with the content by keeping the aspect ratio intact. And when the content is fully filled it get's out of the bounds either width wise or height wise.

In order to keep the content mode to Aspect Fill for UIImageView you should also set it's Clip Subview's property as well. Setting this property will clip the content of the image view outside the bounds.

Sanjay Mohnani
  • 5,947
  • 30
  • 46
  • here is what i got :/ http://s15.postimg.org/oknmpff0b/Screen_Shot_2015_04_30_at_1_27_08_PM.png – OXXY Apr 30 '15 at 10:27
  • @OXXY, I think you need to show the image without losing any of it's content also keeping it's aspect ratio intact – Sanjay Mohnani Apr 30 '15 at 10:34