Label basic use method, 1 Create, 2、 set display content, 3、 set text font or size, 4、 set background color or foreground picture, 5, set font line number or wrap line
uilabel* _label = [[Uilabelalloc]initwithframe:cgrectmake (WIDTHOFTHECOLUMNSHOULDBE * 0.5 + (I *
Set content
_label.text = [NSString stringwithformat:@ "%.1f", ecolumn.grade*100];
Specify font and size
[_labelsetfont:[uifont fontwithname:@ "Helvetica" size:12.0]);
Set Font size
_label.font = [Uifont systemfontofsize:10.0];
Clear background color
_label.backgroundcolor = [Uicolor Clearcolor];
Set font color to red
_label.textcolor = [Uicolor Redcolor];
Center text display
_label.textalignment =nstextalignmentcenter;
Automatic line break setting
_label.linebreakmode =nslinebreakbywordwrapping;
Set number of lines, 0 line Wrap
_label.numberoflines = 0;
Set background picture
Uicolor *color = [Uicolor colorwithpatternimage:[uiimageimagenamed:@ "Itemkaung2.png"]];
[_label Setbackgroundcolor:color];
Set text alignment
_label.textalignment =nstextalignmentleft;
_label.textalignment =nstextalignmentcenter;
_label.textalignment =nstextalignmentright;
To set the vertical or oblique display
_label.transform=cgaffinetransformrotate (ecolumnchartlabel.transform,-m_pi/-4);
Set some text to a different color or font
nsstring* content = [NSString stringwithformat:@ "%@:%@", Prisemodle.sender_name, prisemodle.content];
Cgsize size = [NSString calculatetextheight:content_font giventext:content givenwidth:250];
nsmutableattributedstring *str = [[Nsmutableattributedstring alloc] initwithstring:content];
Set the first 5 words to red
[Str addattribute:nsforegroundcolorattributename value:[uicolor Redcolor] Range:nsmakerange (0,5)];
uilabel* replylable = [[Uilabel alloc] Initwithframe:cgrectmake (5, resizelabely, and Size.Height)];
Set Uilabel text
Replylable.attributedtext = str;