Uilabel controls in iOS

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.