Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create label programmatically [closed]

Tags:

iphone

I am a beginning iPhone developer. I want to create a UILabel programmatically, and I want to know all of the properties and functionality of the UILabel class.

like image 254
Gopal Avatar asked Mar 26 '11 14:03

Gopal


2 Answers

UILabel *label = [[[UILabel alloc] initWithFrame:...] autorelease];
// Do some stuff
[self.view addSubview:label];

UILabel reference: http://developer.apple.com/library/ios/#documentation/uikit/reference/UILabel_Class/Reference/UILabel.html

like image 65
unexpectedvalue Avatar answered Oct 02 '22 17:10

unexpectedvalue


Use this code.

UILabel *lbl1 = [[UILabel alloc] init];
[lbl1 setFrame:CGRectMake(0,5,100,20)];
lbl1.backgroundColor=[UIColor clearColor];
lbl1.textColor=[UIColor whiteColor];
lbl1.userInteractionEnabled=YES;    
[self.view addSubview:lbl1];
lbl1.text= @"TEST";
like image 32
D.M Patel Avatar answered Oct 02 '22 15:10

D.M Patel