Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference b/w Redraw and Scale to Fill Mode in UIImageView?

For an UIImageView, different mode options are given In the interface builder like Aspect Fit, Aspect Fill. Can anyone tell me what is the difference b/w these two modes: Scale to Fill VS Redraw?

like image 869
Jamal Zafar Avatar asked Aug 30 '12 11:08

Jamal Zafar


1 Answers

UIViewContentModeScaleToFill

For the first time, drawRect: is called and view is rendered. Later, when geometry changes, drawRect: is not called and already rendered content is scaled to draw the view.

UIViewContentModeRedraw

Every time you change bounds, drawRect: is called to render the view again, again and again. Unless you know what are you really doing and unless you really need it, don't use it. It's much slower, because it must call drawRect: again and again. In other words, when you set UIViewContentModeRedraw it's same behavior as when you call setNeedsDisplay every time bounds are changed.

Simplified explanation, but should clarify it a bit for you.

like image 133
zrzka Avatar answered Oct 23 '22 15:10

zrzka