Use AutoLayout to set the same spacing for multiple buttons

Source: Internet
Author: User

In storyboard, if you want to set multiple buttons with AutoLayout in the same spacing, and adjust the spacing according to the width of the screen, I understand that there is no direct setup method. Only using the Storyboard+ code method to implement

1, first place four buttons in storyboard, and select them at the same time


2, set wide, high, supview the distance of the lower boundary and other constraints

Font3, select the first button when Setup is complete


4, set its constraint from the left edge


5, set a second, and so on


6, write the Iboutlte in the code, which is four buttons to the edge of the constraint and the width of one of the buttons constraints


7, select Viewcontroller


8, start connecting.




9, write down the following code in Viewcontroller

Use AutoLayout to set the same spacing for multiple buttons

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.