iOS Auto layout

Source: Internet
Author: User

My main job this week was to start the development of iOS. I also bought a new Mac, and when I started developing iOS I found a problem with the layout, models, iphone4,4s, 5,5s,6, 6plus maddening.

So many versions, if one for writing that would be too troublesome to be too troublesome, so I think of the Android Dp,ppi but not in iOS, fortunately iOS has been a different screen for this model to do the job.

Let me introduce you to the use of relative layouts in Interface Builder in Xcode:

First I create a blank project

Click on the. xib file or the storyboard layout file, and drag the controls from the toolbar on the right to the layout file to layout them.

Click on the tab above to change the toolbar type

The focus is on the relative layout of the Constraints add control-click Controls to drag to add constraints you want to add constraints to yourself (such as controlling the width of the control) and drag to yourself.

On the right side of the toolbar see descendant Constraints is the constraint you added click to modify

Interfaces such as Iphone6 and iphone4s

I designed the fashion above the red button with the top left to the right bottom of the distance fixed, so on any screen red button will be horizontally filled with the screen, look at the bottom of the two small buttons below the right button is always snapped to the bottom right of the screen, The lower left button always snaps to the bottom left of the screen. That's relative layout. I hope it helps everyone.

iOS 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.