Code for creating custom Label in Xcode?

UILabel *_lblTitle=[[UILabel alloc]initWithFrame:CGRectMake(x,y,w,h)];
    [_lblTitle setText:[[NSString alloc]initWithFormat:@”Add label text here”]];
    [_lblTitle setTextColor:[UIColor redColor]];  // Add your color here.
    [_lblTitle setBackgroundColor:[UIColor grayColor]]; // Add your background color here.
    [_lblTitle setFont:[UIFont systemFontOfSize:15.0]]; // Set your font size here.
    [_lblTitle setNumberOfLines:0];

// Here code for dynamic size length of label.
    _newSizeOfLabel = [_lblTitle.text sizeWithFont:_lblTitle.font
                                 constrainedToSize:_maximumSize  // Defined max size function.
   [cell  addSubview:_lblTitle];


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s