My UILabel
is in UITableViewCell
and Here is my code
lblgoal = [[UILabel alloc] initWithFrame:CGRectMake(60,10, 250, 20)];
CGSize maximumLabelSize1 = CGSizeMake(230,9999);
lblgoal.numberOfLines = 0;
lblgoal.adjustsFontSizeToFitWidth = NO;
CGSize expectedLabelSize = [sg.subgoal_name sizeWithFont:lblgoal.font
constrainedToSize:maximumLabelSize
lineBreakMode:lblsubgoal1.lineBreakMode];
CGRect newFrame = lblgoal.frame;
newFrame.size.height = expectedLabelSize.height;
lblgoal.frame = newFrame;
But this only works if i put the width of UILabel
to 200, if i put more than 200 width, then it all comes in one line with dotted at the end. And, UITableView
cell width is more than 500.