Uilabel is also a fairly common control, mostly used to display a piece of text, so a common method is to set some of the text within the control.
1 //Text Labels2UILabel *label =[[UILabel alloc]init];3Label.frame = CGRectMake (Ten, -,355, -);4Label.backgroundcolor =[Uicolor Yellowcolor];5 //text6Label.text =@"Hello.iosghuirhgoireghoieughsiuhgfsuidhgiusfdghfidsughfdiushvdfisubvusfhjifohweuhfueoighreugh";7 //Text layout mode8Label.textalignment =Nstextalignmentcenter;9 //text colorTen /* One Clearcolor-Clear Color A */ -Label.textcolor = [Uicolor colorwithred:0.24Green0.12Blue0.51Alpha1]; - //Label.alpha = 0.5; the //Settings for Fonts -Label.font = [Uifont systemfontofsize: -]; - //font bold or italic -Label.font = [Uifont boldsystemfontofsize: -]; +Label.font = [Uifont italicsystemfontofsize: -]; - for(NSString *nameinch[Uifont Familynames]) { +NSLog (@"%@", name); A } atLabel.font = [Uifont fontwithname:@"Bodoni Oldstyle"Size -]; - //Set Shadow -Label.shadowcolor =[Uicolor Redcolor]; -Label.shadowoffset = Cgsizemake (-1,-1); - //1.label to be of sufficient size - //2. Set the line break mode inLabel.linebreakmode =nslinebreakbywordwrapping; - //3. Set the number of rows displayed (0 can not limit the number of rows) toLabel.numberoflines =0; + //* * Calculates the size of a label based on the string size -Cgsize size = [Label.text sizeWithFont:label.font constrainedtosize:cgsizemake (355,10000) linebreakmode:nslinebreakbycharwrapping]; theLabel.frame =CGRectMake (label.frame.origin.x, LABEL.FRAME.ORIGIN.Y, Label.frame.size.width, size.height); *[Self.view Addsubview:label];
Uilabel controls in iOS