UIImageView Content Modes

Oscar de la Hera Gomez
A flower that represents Swift next to a flower that represents XCode. Beneath it sits the text that states '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

Scale Aspect Fit

Available using .scaleAspectFit.

Sample screenshot of the scale aspect fit content mode.

Scale Aspect Fill

Available using .scaleAspectFill.

Sample screenshot of the Scale Aspect Fill content mode.

Scale To Fill

Available using .scaleToFill.

A screenshot of the scale to fill content mode.

What other modes are available?

Top

Available using .top.

A screenshot of the top content mode.

Available using .right.

A screenshot of the right content mode.

Center

Available using .center.

A screenshot of the center content mode.

Bottom

Available using .bottom.

A screenshot of the bottom content mode.

Left

Available using .left.

A screenshot of the left content mode.

Redraw

Available using .redraw.

A screenshot of the redraw content mode.

Bottom Left

Available using .bottomLeft.

A screenshot of the bottom left content mode.

Bottom Right

Available using .bottomRight.

A screenshot of the bottom right content mode.

Top Left

Available using .topLeft.

A screenshot of the top left content mode.

Top Right

Available using .topRight.

A screenshot of the top right content mode.

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.

delasign logo

Book a Free Consultation.

An icon of an email.

Click here to email us.

Fill in the details below to book a free consultation or to let us know about something else. Whatever it is, we are here to help.

How can we help you ?

Contact Details