Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm the author of FXLabel, and whilst I don't know Manish, I believe he was trying to help (if he was advertising for me, I certainly didn't ask him to, and I'm not paying him - sorry Manish!).</p> <p>One of FXLabel's features is that it respects the UIContentMode property of the label, as set in Interface builder. This means you can set label.contentMode = UIViewContentModeTop; to align the text to the top of the label view (which doesn't work for a regular UILabel). The relevant example is here:</p> <blockquote> <p><a href="https://github.com/nicklockwood/FXLabel/tree/master/Examples/Text%20Alignment" rel="nofollow">https://github.com/nicklockwood/FXLabel/tree/master/Examples/Text%20Alignment</a></p> </blockquote> <p>FXLabel is a drop-in subclass of UILabel, so I think it's a pretty good solution for the question being posed. However if the poster would rather solve the problem without using a 3rd party library (which is understandable) then here is the code to do it:</p> <pre><code>CGRect labelFrame = CGRectMake(22, 50, 280, 150); UILabel *myLabel = [[UILabel alloc] initWithFrame:labelFrame]; [myLabel setText:finalRecipe]; [myLabel setBackgroundColor: [UIColor lightGrayColor]]; [myLabel setNumberOfLines:0]; CGFloat fontSize = 0.0f; labelFrame.size = [myLabel.text sizeWithFont:myLabel.font minFontSize:myLabel.minimumFontSize actualFontSize:&amp;fontSize forWidth:labelFrame.width lineBreakMode:myLabel.lineBreakMode]; myLabel.frame = labelFrame; [self.view addSubview:myLabel]; </code></pre> <p>Note:(This is untested, so apologies if there are any typos)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload