Uilable is the most basic control of the iphone interface and is used primarily to display textual information.
Basic methods of Use:
UILabel *label = [[UILabel alloc]initwithframe:cgrectmake (x,y,w,h)]; //Initialize
Label.center = Self.window.center; //Set label to center relative to window
Label.text = @ "UILabel"; //Set text content
NSLog (@ "%@", Label.text); //Read content
label.highlighted = YES; //Whether highlight
Label.highlightedtextcolor = [Uicolor Yellowcolor]; //color of the font when highlighted
Label.background = [Uicolor Redcolor]; //Set the label's background color
Label.font = [Uifont systemfontofsize:14]; //Set text font size (default font Size: 17), general method
Label.font = [Uifont boldsystemfontofsize:14]; //Bold method
Label.font = [Uifont fontwithname:@ "Arial" size:14]; //How to specify Fonts
Label.textcolor = [Uicolor Bulecolor]; //Text color
Label.shadowcolor = [Uicolor Graycolor]; //Set shadow color
Label.shadowoffset = Cgsizemake ( -4,-4); //Set the amount of partial yin
// when the text is longer than frame range, text interception method:
Label.linebreakmode = Nslinebreakbytruncatingtail; The contents of the//end section are omitted in the "text ..." mode, displaying the text content of the header.
Nslinebreakbytruncatinghead; ///Front part of the text with "... Text " way omitted, display trailing text content.
Nslinebreakbytruncatingmiddle; //middle content with "text ... the text "way omitted, displays the text content of the tail and kinsoku.
nslinebreakbywordwrapping; //Displays the word as the display unit, and the trailing part is omitted.
nslinebreakbyclipping; //Simple tailoring, up to the border
nslinebreakbycharwrapping; //Preserve entire characters
To set the alignment of a font
Label.textalignment = Nstextalignemtcenter; //Center alignment
Nstextalignmentleft; //Align Left
Nstextalignmentright; //Right Justify
Label. adjustsfontsizetofitwidth = YES; //Set font size to fit label width
Label. NumberOfLines = 0; //Set number of rows, when =0, indicates no limit on number of rows, for multiple lines
[Label SizeToFit]; //label according to the content, with the above numberoflines,adjustsfontsizetofitwidth settings conflict, can only use one of the
label.baselineadjustment = Uibaselineadjustmentnone; //The lowest end of the text is aligned with the label centerline. (If the adjustsfontsizetofitwidth property is set set to Yes, this property controls the behavior of the text baseline. )
uibaselineadjustmentaligncenters; the middle of the text is aligned with the label centerline.
Uibaselineadjustmentalignbaselines = 0; //default, the top of the text is aligned with the centerline.
label.enable = no; //enabled just determines how the label is drawn, setting it to no will darken the text, indicating that it is not active, and setting a color value to it is not valid.
Label.adjustsletterspacingtofitwidth = NO; //Whether to change the spacing between letters to fit the label size
Vertical text displays each text plus a newline character, which is the most convenient and easy way to implement:
Label.text = @ "please \ \ \ \ \ \ \ \ \ \ \ \ \ \"
Label.numberoflines = [Label.text length];
Set the label's border color, thickness
Label.layer.borderColor = [[Uicolor graycolor] cgcolor];
Label.layer.borderWidth = 5;
(May learn relatively shallow, if you have to add can leave a message, there are questions to discuss with you, you can contact privately: Qq790444804:hgwchihuo
-------I'm a happy little tail ' (*∩_∩*)
Uilable Related foundation of Ios:ui design