Sizeclasses detailed
IOS 8 Adds a new feature-size Classes to the visual design of the application interface. For any device, the width and height of the interface are divided into three descriptions: compact, Arbitrary and loose. This allows developers to ignore the specific dimensions of the device and adapt the two classes and their combinations.
Why Apple launches Sizeclasses
- Iphone3gs-4s:frame write directly to death.
- Ipad:autoresizing-> changes according to the parent control frame, and the child controls are changed along with each other.
- Iphone5-iphone5s:autolayout-> Automatic layout.
- IPhone6 and Iphone6p:size classes-> found that the screen became too diverse and the interface had to be unified.
Sizeclass
- Just sort the screens and actually arrange the UI elements to use AutoLayout
- There is no longer a concept of the screen size, only the concept
- No longer have the concept of specific dimensions, only the concept of abstract dimensions
Sizeclass the width and height into 3 different cases.
- Compact: Tight (small)
- Any: arbitrary
- Regular: Loose (Large)
The symbol in Sizeclass represents
- Compact:-
- Any: *
- Regular: +
Inheritance of
W:compact h:compact Inheritance (w:any h:compact, W:compact h:any, W:any h:any)
W:regular h:compact Inheritance (w:any h:compact, W:regular h:any, W:any h:any)
W:compact h:regular Inheritance (w:any h:regular, W:compact h:any, W:any h:any)
W:regular h:regular Inheritance (w:any h:regular, W:regular h:any, W:any h:any)
Device corresponding screen
Iphone4s,iphone5/5s,iphone6
Vertical screen: (w:compact h:regular)
Horizontal screen: (W:compact h:compact)
IPhone6 Plus
Vertical screen: (w:compact h:regular)
Horizontal screen: (W:regular h:compact)
Ipad
Vertical screen: (W:regular h:regular)
Horizontal screen: (W:regular h:regular)
Apple Watch (guess)
Vertical screen: (w:compact h:compact)
Horizontal screen: (W:compact h:compact)
The role of Sizeclass and AutoLayout
Sizeclass: It's just a sort of screen.
AutoLayout: Constrain the various elements in the screen (position \ Size)
The above is an introduction to the simple concept of sizeclasses.
The following will be used to introduce (more graphic introduction)
Figure I (overall project)
Figure II (we can go to the user interface by clicking on the Tuyi point)
Figure three (see figure II I think you will think what this is to the above text has what relationship?) Then figure three will get them connected.
Using figure three allows us to connect the graph to the text, but it's not clear how to use it, so let's take a look at the examples below.
Instance one: When a view is displayed on a vertical screen, it is not displayed on a horizontal screen. (illustrated below)
Display on portrait (add view when vertical)
Horizontal screen does not display (because we are added in the vertical screen, do not do the operation on the horizontal screen)
Let's take a look at the example results:
Result one:
Result two (don't doubt your eyes are white?? )
Note: Be sure to use constraints when using sizeclasses.
Through this example we can learn the most basic use of sizeclasses.
Example two: ipad is not the same as it appears on the iphone
If you set it up
You can understand the picture according to the corresponding symbol in the previous article.
Here are the test results
ipad test Results
iphone test Results
IOS Sizeclasses Detailed