Search This Blog

Thursday, August 20, 2015

Difference between “Use auto layout” and “Use size class” in xcode 6.1?

They are two entirely different things.

Auto Layout:

"Use Auto Layout" determines whether a storyboard uses the Auto Layout features introduced in iOS 6 to automatically layout your interface using constraints.

“Auto Layout is a system that lets you lay out your app’s user interface by creating a mathematical description of the relationships between the elements. You define these relationships in terms of constraints either on individual elements, or between sets of elements.”

Size class:

Size classes require Auto Layout. If the checkbox Use Auto Layout isn’t selected when you select Use Size Classes, Xcode prompts you to enable Auto Layout.

"Use Size Classes" enables a new Xcode 6 feature called size classes that lets you use Auto Layout to build one interface for all devices and customize constraint constants, and certain views and constraints for different interface idioms while reusing the general layout. It saves the work and repetitiveness of having to build and maintain both MainiPhone and MainiPad storyboards.
 
Size Classes let you set different constraints for certain screen sizes. This let’s you go beyond basic stretching layouts.In Xcode 6 Apple introduced Size Classes.


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.



 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.




Use size classes to enable a storyboard or xib file: to work with all available screen sizes. This enables the user interface of your app to work on any iOS device.
With size classes, a storyboard or xib file can be used for any available screen area. You build your interface as it will look in most sizes, then update only the parts that need to change when the available screen size changes.
A size class identifies a relative amount of display space for the height and for the width. Each dimension can be either compact, for example, the height of an iPhone in landscape orientation, or regular, for example, the height or width of an iPad. Because much of the layout of an app does not need to change for any available screen size, there is an additional value, any.
The available screen size for a view controller is based on 3 factors:
  • The screen size of the device.
  • The orientation of the device.
  • The portion of the screen available to the view controller. For example, when a split view controller displays both the master and detail controllers, neither controller has access to the full screen.
To create a view controller that uses size classes, begin by laying out your design abstractly—a height and width size class of any. To design for more specific available areas, choose appropriate size classes. As needed, add or remove views, change the font used to display text, and add, remove, or edit constraints. In this way, you can more easily deploy your app to different devices in various orientations.
You can change four aspects of presentation in a size class. For constraints, you can change the constant for a constraint and you can change whether the constraint is installed in the view hierarchy. For views, you can change whether a view is installed in the view hierarchy and you can change the font used to display text.
These four changes enable you to adapt your interface for a size class by:
  • Changing the size or position of views
  • Adding or removing views
  • Adding or removing constraints
  • Changing the font in labels, fields, text views, and buttons
As you design your app, preview how its layout appears on specific devices from within Xcode.

No comments:

Post a Comment