title: Having difficulty wrapping text
body: <p>I use the following code to add text in IOS</p>
  
  <pre><code>//Set up label frame
  UILabel *tempLabel = [[UILabel alloc]initWithFrame:CGRectMake(100, 10, 210, 80)];
  self.answer_text_label = tempLabel;
  [tempLabel release];    
  [self.preview_answer_container addSubview:self.answer_text_label];
  
  //Populate label with text
  self.answer_text_label.text = self.answer.text;
  self.answer_text_label.numberOfLines = 4;
  self.answer_text_label.lineBreakMode = UILineBreakModeWordWrap;
  [self.answer_text_label sizeToFit];
  </code></pre>
  
  <p>However, the result I get is as such, the text seems to overflow to the right instead of staying within the frame as stipulated in my label setup 'CGRectMake(100, 10, 210, 80)'</p>
  
  <p><img src="https://i.stack.imgur.com/bpUAy.png" alt="enter image description here"></p>
  
  <p>The wrapping works if I change to <code>self.answer_text_label.numberOfLines = 0</code>. But this will not work for me since I need to constrain the text within my stipulated label frame.</p>
  
  <p>Any way I can wrap the text and keep to only 4 lines?</p>
  
  <p>EDIT:</p>
  
  <p>Try the suggested code</p>
  
  <pre><code>self.answer_text_label.text = self.answer.text;
  [self.answer_text_label sizeToFit];
  CGRect labelRect = self.answer_text_label.frame;
  labelRect.origin.y = CGRectGetMaxY(labelRect);
  labelRect.size = self.answer_text_label.frame.size;
  self.answer_text_label.frame = labelRect;
  </code></pre>
  
  <p>result as follows. Did not seem to solve my problem</p>
  
  <p><img src="https://i.stack.imgur.com/czXJv.png" alt="enter image description here"></p>