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)