Adaptive Layout in Xcode 8

11,649

Solution 1

Now you have "Use Trait Variations" which is improved version of Size Classes

enter image description here


You can now select device based and orientation based trait view much like size classes (iPad Pro, iPad, iPhone 6Splus, iPhone 6s, iPhone SE and iPhone 4s)

enter image description here

Solution 2

Apple introduce new feature called Trait Variations.

Trait Variation

So now you can simply create how it looks on real device.

enter image description here

You can simply switch devices by just clicking and also change the orientation of your view.

Share:
11,649
Khawar
Author by

Khawar

Updated on July 18, 2022

Comments

  • Khawar
    Khawar almost 2 years

    I am developing app using Xcode 8 (beta 1). Unfortunately, I am not able to find "Size Classes" option.

    In Xcode 7, there was option "Use Size Classes".

    enter image description here

    But in Xcode 8 there is no such option. Is there any help for using Size Classes or similar in Xcode 8?

  • Satyam
    Satyam over 7 years
    How can I have common layout for all resolutions? w - Any h - Any
  • RyanTCB
    RyanTCB over 7 years
    All iPhones in portrait at wC hR so how to make different layouts for 7+ and 4s sizes?
  • Dhruv Khatri
    Dhruv Khatri over 7 years
    The new layout video is uploaded by apple you can also assign some layout objects for only some devices.
  • RyanTCB
    RyanTCB over 7 years
    I see that video but that's when devices have different Traits. Sadly as all iPhones in portrait have same traits they cant be used to make adaptive layouts
  • Marlon Ruiz
    Marlon Ruiz over 7 years
    Prior to Xcode 8, any needed to be explicit, and in some places you’ll find explicit uses of any still. Often Xcode 8 hides Any from you, making it implicit instead of explicit. This resource could be useful to you: makeapppie.com/2016/09/05/…
  • Tal Zion
    Tal Zion over 7 years
    @DhruvKhatri How can I set different Vary traits for different iPad orientation?
  • Dhruv Khatri
    Dhruv Khatri over 7 years
    Check out this two videos this will guide you @TalZion Check out Making Apps Adaptive, Part 1 from #WWDC 2016 developer.apple.com/wwdc16/222 Part 2 from #WWDC 2016 developer.apple.com/wwdc16/233
  • Ethan Parker
    Ethan Parker about 7 years
    So I have Use Auto Layout and Trait Variations checked, and my view controllers change size on IB, great. But I thought with Size Classes you could change the view in IB, do some work, then it would save those changes ONLY for that size?