DEV Community

Cover image for Content Mode | IOS Swift
Luiz Gabriel for Swift Proof of Work

Posted on • Edited on

1 1

Content Mode | IOS Swift

In this article we will talk about the ways in which elements can be worked with within a view, the value of this property by default comes as .scaleToFill.

We use this property when we want to implement resizable controls. For example, instead of having to redraw every time, we use content mode so that the element adapts as necessary.

.scaleToFill

  • Fills the entire view, so it can lose proportion Image description

.scaleAspectFit

  • Adjusts the content to fit the view while maintaining the aspect ratio, any remaining area is transparent Image description

.scaleAspectFill

  • It fills the view while maintaining the proportion, but the element may go beyond the limits of the view.

Image description

.center

  • Centers the content and maintains the same proportions

Image description

.top

  • Aligns and centers the content at the top of the view

Image description

.bottom

  • Aligns and centers the content at the bottom of the view

Image description

.left

  • Aligns and centers the content on the left side of the view

Image description

.right

  • Aligns and centers the content on the right side of the view

Image description

.topLeft

  • Aligns content to the left at the top of the view

Image description

.topRight

  • Aligns content to the right at the top of the view

Image description

.bottomLeft

  • Aligns content to the left at the bottom of the view

Image description

.bottomRight

  • Aligns content to the right at the bottom of the view

Image description

.redraw

  • Indicates that the view needs to be redrawn every time the size is changed, we use this when the content of the view depends on the view

Image description

Thanks for read this article!

Sentry blog image

The countdown to March 31 is on.

Make the switch from app center suck less with Sentry.

Read more

Top comments (0)

Heroku

This site is powered by Heroku

Heroku was created by developers, for developers. Get started today and find out why Heroku has been the platform of choice for brands like DEV for over a decade.

Sign Up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay