UIImageView Content Modes
A guide to UIImageView content modes in Swift (iOS) and how they alter the image presented to a user.
The following tutorial makes use of the tutorial that we created for adding a UIImage to a UIView and is available on the tutorial/content-modes branch in the repository linked below.
How to alter content modes ?
Use the following line to alter your content mode, where your_content_mode is a UIImageView contentMode.
self.imageView.contentMode = .your_content_mode
What are the popular content modes?
Scale Aspect Fit
Available using .scaleAspectFit.
Scale Aspect Fill
Available using .scaleAspectFill.
Scale To Fill
Available using .scaleToFill.
What other modes are available?
Top
Available using .top.
Right
Available using .right.
Center
Available using .center.
Bottom
Available using .bottom.
Left
Available using .left.
Redraw
Available using .redraw.
Bottom Left
Available using .bottomLeft.
Bottom Right
Available using .bottomRight.
Top Left
Available using .topLeft.
Top Right
Available using .topRight.
Any Questions
We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.