Create label programmatically

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

+4
source share
4 answers
UILabel *label = [[[UILabel alloc] initWithFrame:...] autorelease]; // Do some stuff [self.view addSubview:label]; 

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

+15
source

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"; 
+9
source

Conveniently, Apple provides exactly this right here:

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

For any question of this nature, just go to Google, enter "Class Link" * Something "(where * Something * should be replaced by" uilabel "or" nsstring "or some such objective class c) and follow the result from developer.apple .com.

+3
source

A quick way to get what you are looking for:

Control (or right-click) the class type (in this case UILabel) and select "Go to Definition". Xcode will lead you directly to the header file, where everything is officially announced.

You can also select “Find Text in Documentation” to go to the Xcode document for the class.

(If there are categories or other options available, you will need to select “UILabel Interface”.)

+3
source

Source: https://habr.com/ru/post/1345340/


All Articles