The view is rendered in gray. The untransformed content rectangle is an ugly green. The scaleToFit function takes the view and untransformed content dimensions and calculates a transform that will scale and translate the content rectangle so that:
- It fills the view along one dimension without going outside of it.
- It can be seen in its entirety within the view.
- It is not stretched (retains its original proportions).
You can change the values of the content and untransformed view below to see what transformed content rectangles (rendered in orange) are generated. (Keep in mind that bottom must always be greater than top, and right must always be greater than left, however.)