Uilabel for iOS

Source: Internet
Author: User
// Create uilabel * label1 = [[uilabel alloc] initwithframe: cgrectmake (20, 40,280, 80)]; // set the background color label1.backgroundcolor = [uicolor graycolor]; // set tag label1.tag = 91; // set tag text label1.text = @ "Hello world! "; // Set the label text font and font size label1.font = [uifont fontwithname: @" Arial "Size: 30]; // set the text method label1.textalignment = uitextalignmentcenter; // there are three types of text Alignment Methods: // typedef Enum {// uitextalignmentleft = 0, left alignment // uitextalignmentcenter, center alignment // uitextalignmentright, right alignment; // text color label1.textcolor = [uicolor bluecolor]; // The method for intercepting text beyond the label boundary is label1.linebreakmode = uilinebreakmodetailtruncation. // The following methods are available: 6 // typedef Enum {// uilinebreakmodewordwrap = 0, with spaces as the boundary, the entire word // reserved, and the entire character // uilinebreakmodeclip until the Boundary, start with omitted ...... Replace // uilinebreakmodetailtruncation. It is omitted and ended ...... Replace // uilinebreakmodemiddletruncation, omit the middle, and use ...... Instead, multiple rows act on the last line //} uilinebreakmode; // label1.adjustsfontsizetofitwidth = yes; // when adjustsfontsizetofitwidth = Yes, if the text font is to be reduced, the value // baselineadjustment controls the baseline position of the text. The value label1.baselineadjustment = uibaselineadjustmentaligncenters is valid only when the number of lines in the text is 1; // There are three methods: // typedef Enum {// percent = 0. The default text is top of the label midline aligncenters, // uibaselineadjustmentaligncenters, // The text midline aligncenters, // bottom-end text and label midline alignment //} uibaselineadjustment; // maximum number of lines of text. If the value is 0, label1.numberoflines = 2 is not allowed. // the smallest font, valid when the number of rows is 1. The default value is 0.0 label1.minimumfontsize = 10.0; // text highlight label1.highlighted = yes; // whether the text variable label1.enabled = yes; // remove the label background color // label1.backgroundcolor = [uicolor clearcolor]; // text shadow color label1.shadowcolor = [uicolor graycolor]; // The shadow size label1.shadowoffset = cgsizemake (1.0, 1.0 ); // whether to interact with the user label1.userinteractionenabled = yes; [self. view addsubview: label1]; [label1 release];

Add to favorites

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.