How to use Size Classes and Vary for Traits in iOS?

Save

Hi Folks, I hope you are doing well. Today I am going to explain regarding Size Classes and Vary for Traits in iOS. Size classes are traits assigned to user interface elements, like scenes or views. These are the groups of screen sizes that are applied to the width and height of the device screen. This is very useful when we want to show the different layout in iPhone and iPad for the same User interface. The Size Classes currently exists are Compact and Regular.

In Xcode, the Compact Size Classes are referred with wC (Compact Width) and hC (Compact Height) and Regular Size Classes are referred with wR (Regular Width) and hR (Regular Height).

In Storyboard at the bottom, you can see which Size Classes is currently selected with respect to the selected device. Also, you can change the orientation to change the size classes.

 

For more information on size classes according to Devices, you can visit http://www.sizeclasses.com/

Previously some programmers maintain two or more storyboard for different layouts.

Let’s understand the usefulness of the size classes by creating a small demo project. Follow the steps with me:

Two options will appear as shown below.

 

Now your layout is ready to run on the device.

 

 

 

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


2 comments

  • Anonymus
    is it limited on iPhone 8 device or for all devices…?
    • Debabrata Roy (Moderator)
      This tutorial will work on all devices including iPads.
  • css.php

    Great Product, Great Team, and Great Support Service. And if you want to add more features to the product, they can submit any idea that comes to your mind. They really care about their clients and we are really happy and honored to deal with Webkul.

    Osama
    Talk to Sales

    Global

    Live Chat
    Start a Project


      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home