Use Size Classes in Xcode 6 beta

2019-03-08 21:25发布

问题:

Built a new project from scratch in Swift in Xcode 6 (Beta 1) and see File Inspector of Storyboard. There is Use Size Classes below Use Auto Layout. This is the screenshot of this.

1) What is Use Size Classes?

2) Is it related with iPhone 6 screen size?

回答1:

Size classes let's you create a single storyboard irrespective of the device. Brings the joy of adaptive layouts(layouts for different canvas sizes instead of specific device, could be compact or regular) More generally a single app for all devices. Now focus on laying out your design abstractly as if for a generic device.

From Whats new in Xcode

Size classes

Size classes for iOS 8 enable designing a single universal storyboard with customized layouts for both iPhone and iPad. With size classes you can define common views and constraints once, and then add variations for each supported form factor. iOS Simulator and asset catalogs fully support size classes as well.

Essentially you just want to create a single storyboard for all layouts iPhone3.5",iPhone4",iPhone6(who knows its size), iPad... You can even design separate layouts for a specific size devices but you are not gonna create a second storyboard. When you lay out user interface items on the Interface Builder canvas in the Any Width | Any Height combination, the layout applies to all sizes of devices for which your app targets.

For more info: Size class design help

NB: Size class is working fine in iOS7 also. I just tested it on iOS7 simulators. If you have any problems in device let me know i will update my answer.