Can we use Auto Resizing and Auto Layouts in one Project?

539 Views Asked by At

I am starting a new project.In that I need to use both auto layouts and auto resizing. Is it possible to do so ?

2

There are 2 best solutions below

0
Ritesh On

Yes you can use but Use autolayout in the superview with constraints [this helps when there are changes in the space in the View due to different devices(such as 3.5 or 4 inches retina)] and use autoresize for resizing the GUI objects in a view [this helps when there are changes in the space in the View during the orientation of the device]

0
iVarun On

Yes you can use AutoLayout and AutoResizing in one Project.

If you want to turn off AutoLayout for particular storyboard follow below steps.

  1. click on storyboard.
  2. Click on Show the File Inspector.
  3. Uncheck Use Auto Layout (This is by default turn on (Checked) )

enter image description here

If you want to turn off AutoLayout programmatically for particular view follow below steps:

  • Take IBOutlet of UIView.

write below code:

view.translatesAutoresizingMaskIntoConstraints = true
view.autoresizingMask = [.flexibleWidth, .flexibleHeight]

Hope this will help you.