iOS Development Project Article-10 alignment

Source: Internet
Author: User

iOS Development Project Article-10 alignment

One, about the four easy to confuse attribute comparison explanation

1. textaligment : Alignment of the horizontal direction of the text

(1) value

Nstextalignmentleft = 0,//left Justified

Nstextalignmentcenter = 1,//center alignment

Nstextalignmentright = 2,//Right Justified

(2) Which controls have this property: A control that is generally capable of displaying text has this property

* Uitextfield

* UILabel

* Uitextview

2. contentverticalalignment : Vertical alignment of content

(1) value

Uicontrolcontentverticalalignmentcenter = 0,//center alignment

Uicontrolcontentverticalalignmenttop = 1,//top aligned

Uicontrolcontentverticalalignmentbottom = 2,//Bottom alignment

(2) Which controls have this property: The control that inherits from Uicontrol or the Uicontrol itself

* Uicontrol

* UIButton

* Uitextfield

3. contenthorizontalalignment : Alignment of the horizontal orientation of the content

(1) value

Uicontrolcontenthorizontalalignmentcenter = 0,//center alignment

Uicontrolcontenthorizontalalignmentleft = 1,//left Justified

Uicontrolcontenthorizontalalignmentright = 2,//Right Justified

(2) Which controls have this property: The control that inherits from Uicontrol or the Uicontrol itself

* Uicontrol

* UIButton

* Uitextfield

4. contentmode : Content Mode (controls the alignment of content), generally useful for uiimageview

(1) value

Rule :

1. Scale: The picture will stretch

2.Aspect: Picture will maintain the original aspect ratio

In the first 3 cases, the picture will stretch

(default) stretches the picture to fill the entire uiimageview (the picture will be displayed in the same size as the Uiimageview)

Uiviewcontentmodescaletofill,

Scale to fit the entire uiimageview (the image cannot exceed the Uiimageview size range) According to the original aspect ratio of the image.

Uiviewcontentmodescaleaspectfit,

Stretch to the width of the picture as the width of the uiimageview or the height of the image as the height of the Uiimageview, as the image's original aspect ratio is scaled.

Uiviewcontentmodescaleaspectfill,

All subsequent cases will be displayed in the original size of the image and will not be stretched

Uiviewcontentmoderedraw,//When the size of the control changes, it is redrawn once (call Setneedsdisplay again, call DrawRect:)

Uiviewcontentmodecenter,

Uiviewcontentmodetop,

Uiviewcontentmodebottom,

Uiviewcontentmodeleft,

Uiviewcontentmoderight,

Uiviewcontentmodetopleft,

Uiviewcontentmodetopright,

Uiviewcontentmodebottomleft,

Uiviewcontentmodebottomright,

(2) Which controls have this property: All UI controls have

5. If there are multiple properties that conflict, only 1 are valid (nearest principle)

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.