Xcode6 study AutoLayout A

Source: Internet
Author: User

IOS8 came, Xcode also upgraded to 6, but I even autolayout, even storyboard will not use.

Manual code codes are defined by the macro to adapt the interface, so when the iOS7 out of the time also did not change the UI habits. Now iOS8 out, Sizeclass AutoLayout a time overwhelming. I was half dead and I felt I was out of the way. Hurry to learn storyboard,autolayout ...

But until today finally have time to see AutoLayout, good again before, to storyboard don't understand, first read a blog

http://blog.csdn.net/u010990519/article/details/38417381, the blog through the talk of very exciting, like one!


Now create a new project, set up the following UI, if it is still not storyboard, just look at the top of the blog,


The UI is as follows:



Sizeclass Select all of the vertical screen iphone



Ok, the UI is ready, just put a label on it and try AutoLayout.




Label affixed, and began to use AutoLayout, in order to be able to replace the auto, the label added to the control in the lower right corner, through the long-term screen test.





There are tools to add constraints to the Xcode toolbar, and the storyboard panel. Note: Their order is not corresponding.

First use the storyboard panel to add a constraint that is 20 pixels from the right side of the screen:



To add a constraint:



This place has a more important place is to remove the hook, because do not remove there will be an internal margin, resulting in a label with superview more than 16 pixels away (if you set the constraint to 20, the actual is 36);

The effect after adding:



A frame that is not bound to a fixed label, and adds a constraint that is 20 pixels from the bottom of the line




I don't run the code right now like I see the effect now:






The width of the label is adapted to the content.

Now run to see the effect!!



The background is white, a few pieces can see the effect is the bottom right corner 20-20


Continue later ...








Xcode6 study AutoLayout A

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.