-2

I'm trying to resize the uilabel using content, I tried in autolayout ios with cgrectmake, but it's not working.

cell.msglabel=[[UILabel alloc] initWithFrame:CGRectMake(10, 100, myLabel.frame.size.width, myLabel.frame.size.height)];
cell.msglabel.lineBreakMode = NSLineBreakByWordWrapping;
[cell.msglabel setFrame:CGRectMake(10, 10, myLabel.frame.size.width, myLabel.frame.size.height)];
cell.msglabel.text=text;
[cell.msglabel updateConstraints];
syntonym
  • 6,238
  • 2
  • 22
  • 41
J Karthik
  • 1
  • 1

1 Answers1

1

UILabel is intrinsicContentSize view which you need not to set frame directly when you using auto layout.

Give edge constraints is enough, width/height constraint are not necessary. eg. left padding and top padding to other views.

John Henry
  • 46
  • 3
  • tried John Henry as u said still my uilabel content is not geting incresed height and number of lines aumatically based on content – J Karthik Sep 02 '16 at 10:27
  • yes u r right label are intrinsicContentSize we just give to edge constraints and number of lines tanq – J Karthik Sep 02 '16 at 11:05