iOS screen adaptation Scheme-auto Layout

Source: Internet
Author: User

There are a plethora of Android phones on the market. Screens of all sizes make Android programmers more headache.

There are also some great gods who have written some blogs and put forward their own views. iOS seems to have a big screen 6+, so the problem with screen adaptation is also dripping, so Apple has its own way-auto Layout.

I beginner iOS. Today I learned the active layout. In the course of learning, after all, there are some knowledge points are not touched, so write this blog to learn more about auto Layout.

Official explanation:
Auto layout is a system that allows you to lay out your application's user interface by creating mathematical descriptive narratives of relationships between elements. --"Auto Layout Guide"
Auto Layout is a constraint-based. Describe the descriptive layout system. --"Taking Control of Auto Layout in Xcode 5-WWDC 2013"
We add a constraint (Constraints) to the layout to position and control the size of the control. Instead of controlling layouts like Android and HTML5, by using properties such as size. iOS controls do not seem to have a size concept, but are completely controlled by constraints.


Open Storyboard. I dragged two controls at the top and bottom. Look at the picture at a glance. The right IPhone4 bottom control is not visible. The iphone6+ control has been biased.

Next see how to solve, first look at a picture:

1. Select the View controller

2. Press and hold the CTRL key. Pull up, select top Space to top Layout guide


At this point we see the line has become orange color, indicating that the constraint is not enough to join. Continue to the left and right pull.
3, the color becomes green even if good.



4, the control of the bottom joins the same constraint.

Test results:

Fit successfully.
Summarize:
Directly say after all should use storyboard+autolayout feeling is not responsible for the argument, but in-depth thinking AutoLayout is very necessary!
For example, using AutoLayout is helpful in the following situations:
When the need to show a lot of content and size is not fixed;
The program needs to support screen rotation (mainly the ipad program.) The iphone app landscape is a bit of a non-mainstream scene, and it's not ruled out. Hand-tour:);
But the use of AutoLayout in storyboard has pros and cons. The advantage of course is visualization, the implementation of simple functions is very time-saving, but there are drawbacks, such as accidentally moving a control will confuse those constraints

iOS screen adaptation Scheme-auto Layout

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.