// 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