-(void) Viewdidload { Uilabel *label1 = [[Uilabel alloc]initwithframe:cgrectmake (50.0, 20.0, 200.0, 50.0)]; Uilabel *label2 = [[Uilabel alloc]initwithframe:cgrectmake (50.0, 80.0, 200.0, 50.0)]; Uilabel *label3 = [[Uilabel alloc]initwithframe:cgrectmake (50.0, 140.0, 200.0, 50.0)]; Uilabel *label4 = [[Uilabel alloc]initwithframe:cgrectmake (50.0, 200.0, 200.0, 50.0)]; Uilabel *label5 = [[Uilabel alloc]initwithframe:cgrectmake (50.0, 260.0, 200.0, 50.0)]; Uilabel *label6 = [[Uilabel alloc]initwithframe:cgrectmake (50.0, 320.0, 200.0, 50.0)]; Uilabel *LABEL7 = [[Uilabel alloc]initwithframe:cgrectmake (50.0, 380.0, 200.0, 50.0)]; Set display text Label1.Text = @ "Label1"; Label2.Text = @ "Label2"; Label3.text = @ "label3--label3--label3--label3--label3--label3--label3--label3--label3--label3--label3--"; Label4.text = @ "label4--label4--label4--label4--"; Label5.text = @ "label5--label5--label5--label5--label5--label5--"; Label6.text = @ "Label6"; Label7.text = @ "Label7"; Set font: Bold, Normal is systemfontofsize Label1.font = [Uifont boldsystemfontofsize:20]; Set Text color Label1.textcolor = [Uicolor Orangecolor]; Label2.textcolor = [Uicolor Purplecolor]; Set Text position Label1.textalignment = Uitextalignmentright; Label2.textalignment = Uitextalignmentcenter; Set font size to fit label width Label4.adjustsfontsizetofitwidth = YES; Set the number of lines for a label Label5.numberoflines = 2; Uilabel.backgroudcolor=[uicolor Clearcolor]; You can remove the background color Setting highlighting label6.highlighted = YES; Label6.highlightedtextcolor = [Uicolor Orangecolor]; Set Shadow Label7.shadowcolor = [Uicolor Redcolor]; Label7.shadowoffset = Cgsizemake (1.0,1.0); Setting whether to interact with the user label7.userinteractionenabled = YES; Sets whether the text in the label is variable and the default is Yes label3.enabled = NO; Set the display format for text that is too long Label3.linebreakmode = uilinebreakmodemiddletruncation;//to intercept the middle typedef enum { Uilinebreakmodewordwrap = 0, Uilinebreakmodecharacterwrap, uilinebreakmodeclip,//, cut off the extra parts. uilinebreakmodeheadtruncation,//, cut off the head. uilinebreakmodetailtruncation,//, cut the tail. uilinebreakmodemiddletruncation,//, intercept the middle. } Uilinebreakmode; If the Adjustsfontsizetofitwidth property is set to Yes, this property controls the behavior of the text baseline Label4.baselineadjustment = Uibaselineadjustmentnone; typedef enum { Uibaselineadjustmentalignbaselines, Uibaselineadjustmentaligncenters, Uibaselineadjustmentnone, } uibaselineadjustment; [Self.view Addsubview:label1]; [Self.view Addsubview:label2]; [Self.view Addsubview:label3]; [Self.view Addsubview:label4]; [Self.view Addsubview:label5]; [Self.view Addsubview:label6]; [Self.view ADDSUBVIEW:LABEL7]; [Label1 release]; [Label2 release]; [Label3 release]; [Label4 release]; [Label5 release]; [Label6 release]; [Label7 release]; [Super Viewdidload]; } /* Override to allow orientations than the default portrait orientation. -(BOOL) Shouldautorotatetointerfaceorientation: (uiinterfaceorientation) interfaceorientation { Return YES to supported orientations return (interfaceorientation = = uiinterfaceorientationportrait); } */ -(void) didreceivememorywarning { Releases the view if it doesn ' t have a superview. [Super didreceivememorywarning]; Release any cached of data, images, etc that aren ' t in use. } -(void) Viewdidunload { Release any retained subviews of the main view. e.g. Self.myoutlet = nil; } -(void) Dealloc { [Super Dealloc]; } @end |