teach you to use size Class

Source: Internet
Author: User

In IOS8, we don't have to create multiple xib files to fit different types of screens as we used to, and now we can put the fit of various sizes of screens into one file, and then we can customize the interface of various sizes with different categories of size. In other words, the Storyboard in front of you is not an ordinary Storyboard, but a nine-in-one Storyboard that can manage nine kinds of screens.

For width and height, there are three cases: compact, arbitrary (any), normal (Regular), so there are 3*3=9 categories altogether.

The page will be prompted when the Size Class is set. By default, the width and height are any, for example.

We can see from the Size class setting interface, the above text any width any height is the expression width and height are arbitrary; the text below for all layouts meaning is clearly applicable to all dimensions.

The role of size class is to classify screens of different sizes, and the final layout management is AutoLayout.

Now let's do a little experiment by first adding a center button to the view, as shown in

We then go to the size class's setup interface and set the size to as shown

From the upper text of the size class setting interface, you can see that the width is normal and the height is compact; the for 5.5inch iPhones in landscape can be seen from the text below. Meaning is suitable for 5.5 inch iphone horizontal screen, that is iphone6+ horizontal screen. (As for the other size, I will no longer demo, just show this one, I think everyone can extrapolate). We're going to put a button on the screen this time, like

At this time to run the program can see the effect, we added the first button, whether with iphone4,5 or 6, etc. will appear, but the second Add button, only in the case of iphone6+ horizontal screen will appear. I think you should understand why the second button will only show up on the iphone6+. I'm not going to explain that anymore.

Demo results (iphone6+ vertical screen and horizontal screen)

teach you to use size Class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.