Sizeclass and AutoLayout

Source: Internet
Author: User

The 1.Size class is used with auto layout to make auto layout less complex.

2.Size classes is actually the Size of the iOS device screen is categorized for example: iphone4s horizontal screen wcompact/hcompact, vertical screen wcompact/hregular; IPhone5S (6,6+) Horizontal screen wregular/hcompact, vertical screen wcompact/hregular, ipad screen is wregular/hregular

3. Theoretically if a view does not have any constraint, then the view will have no location and size, but it is no problem at present, what is the solution? If you do not add any constraint to a view, the system will automatically add the left, top, width, and height four constraints to the view, that is, the new Green view will have a fixed width and height, and then to the upper left corner of the screen as a reference point, there is a system to add the default location. (If we add any additional constraints to the Green view, the system automatically adds a constraint that is invalidated)

4. Another problem is that a number of different types of simulators have just been switched, which is equivalent to switching between different size classes, but the green view is normal, and the size class exists to distinguish between different size Class (for example: iphone4s horizontal screen wcompact/hcompact,iphone4s vertical screen wcompact/hregular,ipad screen is wregular/hregular), and then to do a different UI layout, what solution? The current size class is wany/hany, which means that when the size class is Wany/hany, constraint is added, and it takes effect at the other size class. In fact, as can be seen literally, any is any meaning, compact and regular is the subclass of any.

5. Usage of AutoLayout:

A When you need to show a lot of content and size is not fixed;

b programs need to support screen rotation (mainly the ipad program, the iphone app landscape is a bit non-mainstream);

C programs are common to iphone and ipad;

Sizeclass and AutoLayout

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.