I was watching WWDC 2014 411_Whats_new_in_interface_builder session video.On that video the speaker Kevin Cathey told about size classes.He told that there are 2 size classes have 2 values Compact and Regular.He told to think the size class in terms of magnitude of ViewController.He showed an example on Adapting the bar height with respect to four possible combination of size classes.Actually, i couldn't understand the difference what he was trying to talk about I have three questions: 1. What is Compact and Regular Size classes 2. Why size class is useful? 3. How the four combinations of size class affect on simulator(iPhone 5 and 5s etc)? Thanks, Riduan
The Compact Size Class refers to a constrained space. It is denoted in Xcode as wC (Compact width) and hC (Compact height). The Regular Size Class refers to a non-constrained space. It is denoted in Xcode as wR (Regular width) and hR (Regular height).
Size classes are traits assigned to user interface elements, like scenes or views. They provide a rough indication of the element's size. Interface Builder lets you customize many of your layout's features based on the current size class. The layout then automatically adapts as the size class changes.
Size classes help you change the layout of views to adapt to various screen sizes, ranging from a tiny iPhone SE to a massive 12.9” iPad Pro. There are 3 different cases for a size class: regular , compact , and unspecified .
Size Classes are the iOS method of creating adaptable layouts that look great on all sizes and orientations of iPhone and iPad. For example, you might want to say that your UI looks mostly the same in portrait and landscape, but on landscape some extra information is visible.
From Apple Docs:
Size classes are traits assigned to a user interface element, such as a screen or a view. There are two types of size classes in iOS 8: regular and compact. A regular size class denotes either a large amount of screen space, such as on an iPad, or a commonly adopted paradigm that provides the illusion of a large amount of screen space, such as scrolling on an iPhone. Every device is defined by a size class, both vertically and horizontally.
I like to think of them this way: Regular Size Classes : Big screen. Ipad has a regular vertical and regular horizontal size class. Compact Size Classes : Little. In portrait, an iPhone has a compact size class vertically and a regular size class horizontally
If you go into storyboards and enable size classes, you can design for different screens. Do the bulk of your design in the wAnyhAny size class. If you want something specific for the iphone, change the size classes. In the image below if I select Compact Width/Regular Height (as shown), my View in the Storyboard would change to look like an iphone. I could drag in a label, and that label would only show up on iphones in portrait. If I rotate to landscape the label would not appear because it's a different size class.
You can change four things in a size class:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With