iOS

iOS Auto Layouts

iOS Auto Layouts

Auto layouts are used in iOS to ensure applications look the same in portrait and landscape mode across all device sizes. Based on the constraint values that you set for constraints, the auto layout dynamically calculates the size of the view and modifies the controls.

  • You require a user interface that can adapt to numerous devices and orientations automatically.
  • It should be adaptable and versatile so that it can adjust to changing situations.
  • You can accomplish this by utilising the Auto Layout function; it is not an optional feature that you must enable; it is already present, and all you need to do is learn how to use it.

So, let's make a new project called AdaptiveUIDemo and open the storyboard file in it.

At the bottom, you can change the current device perspective.


  • You can choose between portrait and landscape orientations
  • You can choose from various device sizes, including numerous iPad sizes, a Plus-size iPhone, iPhone X, iPhone SE, and even the smallest iPhone 4S.

The ViewController is initially displayed in Xcode roughly the same way it would appear on an iPhone 8 in portrait mode. We've placed multiple labels in each of the four corners.


At the bottom of the storyboard, you can see that we're using an iPhone 8, and we've selected the iPhone 8 Plus simulator in the Xcode toolbar.



Because the iPhone 8 Plus has a larger screen than the iPhone 8, there is some vacant space at the bottom. Let's change the simulator's orientation to landscape.


Select Rotate Left or Rotate Right from the Hardware menu.


Top course recommendations for you

    SQL Triggers for Beginners
    1 hrs
    Intermediate
    12.7K+ Learners
    4.45  (544)
    WordPress with Docker
    1 hrs
    Beginner
    8.9K+ Learners
    4.51  (488)
    C++ Tutorial
    2 hrs
    Beginner
    48.9K+ Learners
    4.43  (2885)
    OOPs Concepts in C++
    2 hrs
    Beginner
    31.1K+ Learners
    4.43  (2082)
    Robotic Process Automation
    3 hrs
    Beginner
    13.1K+ Learners
    4.61  (713)
    Docker Swarm
    1 hrs
    Beginner
    1.7K+ Learners
    4.52  (107)
    Factorial Program in C
    2 hrs
    Beginner
    4.6K+ Learners
    4.43  (155)
    Jenkins Tutorial
    1 hrs
    Beginner
    8.5K+ Learners
    4.5  (599)
    Dockerize Spring Boot Application
    1 hrs
    Intermediate
    3.9K+ Learners
    4.42  (297)
    Python Data Structures
    1 hrs
    Beginner
    30.9K+ Learners
    4.51  (2315)