MultiLine UILabel


In many cases we need a label with multi line. 
For doing this you need to set 2 properties :
1. Number of Lines - 0, it means any number of lines.
2. Line break Mode - WordWrap


CGSize labelsize;
UILabel *TextLabel = [[UILabel alloc] init];
[TextLabel setNumberOfLines:0];
[TextLabel setBackgroundColor:[UIColor clearColor]];
NSString *text=@"yourtextString";
[TextLabel setFont:[UIFont fontWithName:@"Helvetica"size:14]];
labelsize=[text sizeWithFont:TextLabel.font constrainedToSize:CGSizeMake(268, 2000.0) lineBreakMode:UILineBreakModeWordWrap];
TextLabel.frame=CGRectMake(10, 24, 268, labelsize.height);
[cell.contentView addSubview:TextLabel];
[TextLabel release];

Comments

Popular posts from this blog

UITableView - Add or Remove Rows Dynamically (Objective C & Swift Source codes)

payUmoney Payment Gateway Integration in iOS App (Objective C)

Check Internet Connectivity Using AFNetworking 2.0