Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Any" size class missing in Xcode 8

I'm a little confused when seeing the new interface builder's size class options in Xcode 8 beta. I used to build my apps' UI by first design them in "Any" size class and then do some custom adjustments in the other ones. Is the workflow supposed to be changed in this new version of Xcode?

Any size class in Xcode 7

like image 203
FlySoFast Avatar asked Jul 08 '16 01:07

FlySoFast


People also ask

What is size classes in iOS?

In iOS, Size Classes are groups of screen sizes that are applied to the width and height of the device screen. The two Size Classes that exist currently are Compact and Regular. The Compact Size Class refers to a constrained space. It is denoted in Xcode as wC (Compact width) and hC (Compact height).

How do I add constraints in Xcode?

To create constraints select the button and click the Align icon in the auto layout menu. A popover menu will appear, check both “Horizontal in container” and “Vertically in container” options to center the button on the screen. Then click the “Add 2 Constraints” button. Run the application.

How do I use size classes in SwiftUI?

SwiftUI supports size classes natively by exposing them in the environment for us to read. To use them, first create an @Environment object that will store its value, then check the value of that property whenever you need, looking for either the . compact or . regular size class.


2 Answers

The UI to select the size classes has changed in xcode 8. Now it is as follows:

Any constraints that you add without selecting Vary for Traits options will be considered as for all the size classes( Any Any previously)

enter image description here

To add a constraint to a specific size class add it by selecting:

  • The device at the bottom and by selecting Vary for Traits options of that size class.
  • When you are adding constraints to a specific size class the bar turns blue as below

enter image description here

like image 112
Durga Vundavalli Avatar answered Oct 16 '22 09:10

Durga Vundavalli


The way to do this has changed slightly in the new version of Xcode. It should build for "any-any" automatically. Have a look at this WWDC video that I think explains it in detail. There is also a part 2, so watch that if you need to.

https://developer.apple.com/videos/play/wwdc2016/222/

Hope I could help,
Zack

like image 36
Zack Avatar answered Oct 16 '22 08:10

Zack