159

what is the difference between UIViewContentModeScaleAspectFit and UIViewContentModeScaleToFill...?

mfaani
  • 33,269
  • 19
  • 164
  • 293
Madhumitha
  • 3,794
  • 8
  • 30
  • 45

3 Answers3

579

You can see the differences between the content modes here:

enter image description here

Redraw mode works as Scale to Fill mode. But there is a difference in how they are drawn when view geometry changes. Scale to Fill mode uses already rendered content while Redraw mode renders the content again.

erkanyildiz
  • 13,044
  • 6
  • 50
  • 73
191

If you are talking about UIViewContentMode, the following is from the Doc.

UIViewContentModeScaleToFill

Scales the content to fit the size of itself by changing the aspect ratio of the content if necessary.

UIViewContentModeScaleAspectFit

Scales the content to fit the size of the view by maintaining the aspect ratio. Any remaining area of the view’s bounds is transparent.

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
EmptyStack
  • 51,274
  • 23
  • 147
  • 178
  • What is an example of where transparency or clipping would occur? I am picturing a rectangle and it seems as if that clause would never be invoked. – Praxiteles Apr 14 '14 at 05:25
  • Praxiteles, I am not quite understand your question. But from the context of my answer above, clipping will possibly occur in UIViewContentModeScaleToFill & UIViewContentModeScaleAspectFill, if the image ratio does not match the imageView's ratio. Please correct me if I have mistaken your question. Thanks. – EmptyStack Apr 14 '14 at 06:57
132

uiimageview-scaling-explained-visually

enter image description here

Zar E Ahmer
  • 33,936
  • 20
  • 234
  • 300