Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Compact and Regular size class

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

like image 887
MdRiduan Avatar asked Sep 05 '14 20:09

MdRiduan


People also ask

What is compact and regular in iOS?

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).

What are the size classes?

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.

What is the purpose of size classes in Swift?

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 .

What is size class in iOS Swift?

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.


1 Answers

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.
enter image description here

You can change four things in a size class:

  1. The constant for a constraint
  2. If a constraint is installed in the view hierarchy
  3. If a view is installed in the view hierarchy
  4. The font used for many types of views showing text
like image 58
leenyburger Avatar answered Sep 29 '22 02:09

leenyburger