Relative layout log

Source: Internet
Author: User

In the relative layout process, you will encounter a variety of layout problems, organized as follows:

1. Overall centering-*

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7D/50/wKiom1blhaaB-Q2hAAex-D5OuL4834.png "style=" float: none; "title=" 001yayrmgy705550jod33&690.png "alt=" Wkiom1blhaab-q2haaex-d5oul4834.png "/>

In this effect, because all sub-views are not centered, they cannot be centered across the center toward the sides.


The idea is to press the ImageView from left to right by 1-7 numbers, and to the left of each imageview to the right of the previous imageview.

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/7D/50/wKiom1blhbbTdzptAAXTyRaUtOY733.png "style=" float: none; "title=" 2.png "alt=" Wkiom1blhbbtdzptaaxtyrautoy733.png "/>

Then nest a uiview on all ImageView, #1的左边对齐父View的左边, the right side of the parent view aligns to the right of the last ImageView (#7). Then align the CenterX and centery of the parent view to the centerx/centery of the entire view, and the bottom of the parent view aligns the imageview of the bottom two bottom either.


2. Automatic adjustment according to text length in Uilabel-* *

Todo


3. Uitextview height with brother view how much adjustment-* * *

Todo


4. AutoLayout of Swift via Snapkit components-*

Snapkit is a third-party AutoLayout library based on the Swift language, which simplifies the amount of code to set constraints. However, due to its defined constraint object changed from Nslayoutconstraint to constraint, the way of updating the constraint has changed correspondingly, such as the constant method of the commonly used updating related constraints, by Nslayoutconstraint to define constraints, this is usually the case:

Sharecirclebottomconstraint = Nslayoutconstraint (Item:sharecirclesview, attribute:. Bottom, Relatedby:. Equal, Toitem:view, attribute:. Bottom, multiplier:1.0, constant:0) sharecirclebottomconstraint.active = true;

Then call sharecirclebottomconstraint.constant= to update

The constraint is defined by the constraint in Snapkit, which is simplified to:

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/7D/50/wKiom1bliHbwe6p8AACTS4QhVB8816.png "title=" 001yayrmgy7056wekgeee&690.png "alt=" Wkiom1blihbwe6p8aacts4qhvb8816.png "/>

and then call

Sharecirclebottomcontraint.updateoffset (0)

To update

This article is from "Leo's Technical Diary" blog, please be sure to keep this source http://shskey.blog.51cto.com/8310114/1750718

Relative layout log

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.