IOS Xcode6 AutoLayout with size Classes (4) Size Classes app

Source: Internet
Author: User

IOS 8 Adds a new feature to the visual design of the application interface-size Classes, for any device, the width and height of the interface are divided into two descriptions: normal and compact. This allows developers to ignore the specific dimensions of the device and adapt the two classes and their combinations. This way, we can no longer be limited to the specific dimensions, but rather to the visual senses that follow the dimensions, both at design time and in code.

To know that size classes does not help us with automatic layout, but instead helps us to manage different types of IB

But what does it mean to see the width and height of the figure as Any,any? If weight is set to Any,height to regular, then the interface element in that state will exist in the state where the height is regular, whether weight is regular or compact. This relationship should be called an inheritance relationship, and the specific four interface descriptions and inheritable interfaces are described below:
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)

This is the size given by the following apples

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)


Let's experiment.


Create a new project we can see that there is a W any hAny below the Xib (this refers to the width of the heel), and we know that this should be suitable for all sizes, and we'll turn it into the size of the phone.

As follows


We'll go up and drag a few controls, as well as log in and auto-layout you don't know. Read the previous blog post

As follows:

Set the distance from the top neighbor 40 around 20 width to 30 (then its position is not OK, think carefully maybe not).

Let's see the effect.

On the 4:


On the 6 Plus


So it looks like we have no problem with this.

What about the size of a tablet?

As follows


We set the length and width to regular, which is the size of an ipad.

Let's restore the page that we just had and add a third-party login button to the ipad

As follows:


Well, that's about it, let's look at the effect.

On the phone


On the tablet


In general, size classes is a Xib manager that manages all of our size xib and automatically gets the xib of the device and refreshes the Fram of the control according to the device's changes, so that you can fit all the models with one code. Isn't that great? = =


IOS Xcode6 AutoLayout with size Classes (4) Size Classes app

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.