1.textAligment: Alignment of the horizontal direction of the text
nstextalignmentleft = < Span class= "Hljs-number" >0, //left align nstextalignmentcenter = 1, //Center align nstextalignmentright = 2, //right-justified
(UILabel is center-aligned by default and does not provide the top-aligned way-_-, which can be implemented in the following way:)
for(int i=0; i<newLinesToPad; i++) self.text = [self.text stringByAppendingString:@"\n "];
This method is more simple and rude, but effective. The method is to add more \ n after the text.
It is important to note that after \ n is added at least one space, otherwise the extra \ n will be ignored by Uilabel. From this point of view, Uilabel seems to be too "smart". Other ways to achieve label top alignment can be consulted: http://blog.devtang.com/2011/11/20/set-uilabel-text-align-top/
2.contentVerticalAlignment: Vertical alignment of content
UIControlContentVerticalAlignmentCenter = 0, // 居中对齐UIControlContentVerticalAlignmentTop = 1, // 顶部对齐UIControlContentVerticalAlignmentBottom = 2, // 底部对齐
Uicontrol
UIButton
Uitextfield ...
3.contentHorizontalAlignment: Horizontal alignment of content
UIControlContentHorizontalAlignmentCenter = 0, // 居中对齐UIControlContentHorizontalAlignmentLeft = 1, // 左对齐UIControlContentHorizontalAlignmentRight = 2, // 右对齐
A control that inherits from Uicontrol or Uicontrol itself
Uicontrol
UIButton
Uitextfield ....
More 2nd, the 3rd can be conveniently set btn text and pictures of various alignment, such as BTN settings:
Btn.contenthorizontalalignment = Uicontrolcontenthorizontalalignmentleft;
Btn.contentverticalalignment = Uicontrolcontentverticalalignmenttop;
The contents of the button are aligned at the top left corner.
4.contentMode: Content mode (controls how content is aligned), generally useful for Uiimageview
Take value
Law:1.Scale: Picture will stretch2.Aspect: Picture will maintain the original aspect ratio3. Aspectscale */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 stretchedUiviewcontentmoderedraw,When the size of the control changes, it is redrawn once (call Setneedsdisplay again, call DrawRect:)Uiviewcontentmodecenter,Uiviewcontentmodetop, uiviewcontentmodebottom, uiviewcontentmodeleft, uiviewcontentmoderight, Uiviewcontentmodetopleft, uiviewcontentmodetopright, uiviewcontentmodebottomleft, UIViewConten Tmodebottomright,
It is important to note that: If there are multiple properties that conflict, only 1 properties are valid (nearest principle) (for example: BTN Contentmode and Contentverticalalignment are also set). Because the second constraint is directed against BTN, only the second property is valid!)
Summary of various alignments of UI controls in IOS