159

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

0

3 Answers 3

582

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.

0
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.

2
  • 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, 2014 at 5: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, 2014 at 6:57
132

uiimageview-scaling-explained-visually

enter image description here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.