Please get textSize first with the code below:
CGSize textSize = { 230.0, 10000.0 }; CGSize size = [[NSString stringWithFormat:@"%@", yourLabelText] sizeWithFont:[UIFont systemFontOfSize:10] constrainedToSize:textSize lineBreakMode:NSLineBreakByWordWrapping];
then set your first label frame with this content size:
UILabel *lblFirst = [[UILabel alloc] initWithFrame:CGRectMake(X, Y, W, size.height)]; lblFirst.lineBreakMode = YES; lblFirst.lineBreakMode = NSLineBreakByWordWrapping; lblFirst.numberOfLines =size.height; lblFirst.backgroundColor = [UIColor clearColor]; [self.view addSubview:lblFirst];
then the second Frame label will be:
UILabel *lblFirst = [[UILabel alloc] initWithFrame:CGRectMake(lblFollowerName.frame.size.width + lblFollowerName.frame.origin.x, Y, W, H)];
Abhishek Gupta Dec 27 '13 at 10:08 2013-12-27 10:08
source share