title: Why can't I change the frame of my UILabel?
body: <p>I have been trying for two days to modify the frame of a <code>UILabel</code>, which
  is ridiculous... The <code>UILabel</code> is an IBOutlet, but that is not the reason
  why it's not working: I tried to create a <code>UILabel</code> programatically and
  it still didn't work. Here is how I do it:</p>
  
  <pre><code>self.descriptionLabel.text = description;
  self.descriptionLabel.lineBreakMode = NSLineBreakByWordWrapping;
  
  CGSize textSize = [self.descriptionLabel.text sizeWithFont:[UIFont systemFontOfSize:12.0]
                                           constrainedToSize:CGSizeMake(self.descriptionLabel.frame.size.width, FLT_MAX)
                                               lineBreakMode:self.descriptionLabel.lineBreakMode];
  CGFloat frameHeight = textSize.height;
  CGRect frame = self.descriptionLabel.frame;
  frame.size.height = frameHeight;
  self.descriptionLabel.frame = frame;
  
  CGRect bounds = self.descriptionLabel.frame;
  bounds.origin.x = self.descriptionLabel.frame.origin.x + 10.0;
  bounds.size.width = self.descriptionLabel.frame.size.width - 20.0;
  self.descriptionLabel.bounds = bounds;
  self.descriptionLabel.numberOfLines = 0;
  </code></pre>
  
  <p>I already asked on IRC and they told me that there is no reason why the
  frame would not be changed...</p>
  
  <p>I also tried to create a frame with <code>CGRectMake</code> and give it arbitrary
  value but that didn't do the trick either..</p>
  
  <p>Does anyone know what might be the problem please?</p>
  
  <p><strong>Edit 1:</strong> I logged the frame before and after, and I got odd results:</p>
  
  <pre><code>Before: 0.000000 0.000000 0.000000 0.000000
  After: 0.000000 0.000000 0.000000 33525.000000
  </code></pre>
  
  <p>The height after I set the frame is the only value that makes sense (I have a lot of text in the label on purpose).</p>
  
  <p><strong>Edit 2:</strong> I changed the code as follows, the log says that the frame
  changed but on the simulator it didn't change; I proved it by adding red
  borders to the layer of the <code>UILabel</code>.</p>
  
  <pre><code>self.descriptionLabel.text = description;
  self.descriptionLabel.lineBreakMode = NSLineBreakByWordWrapping;
  
  CGSize textSize = [self.descriptionLabel.text sizeWithFont:[UIFont systemFontOfSize:12.0]
                                           constrainedToSize:CGSizeMake(self.view.frame.size.width, FLT_MAX)
                                               lineBreakMode:self.descriptionLabel.lineBreakMode];
  CGFloat frameHeight = textSize.height;
  CGRect frame = CGRectMake(0.0, 300.0, self.view.frame.size.width, frameHeight);
  self.descriptionLabel.frame = frame;
  
  DDLogInfo(@"After: %f %f %f %f", self.descriptionLabel.frame.origin.x, self.descriptionLabel.frame.origin.y, self.descriptionLabel.frame.size.width, self.descriptionLabel.frame.size.height);
  // After: 0.000000 300.000000 320.000000 585.000000
  
  self.descriptionLabel.numberOfLines = 0;
  self.descriptionLabel.layer.borderColor = [UIColor redColor].CGColor;
  self.descriptionLabel.layer.borderWidth = 2;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/ygglX.png" alt="Proof"></p>