Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It is a little more complicated than before and you cannot use a minimum font size, but have to use minimum font scale factor. There is also a bug in the iOS SDK, which breaks it for most use cases (see notes at the bottom). Here is what you have to do:</p> <pre><code>// Create text attributes NSDictionary *textAttributes = @{NSFontAttributeName: [UIFont systemFontOfSize:18.0]}; // Create string drawing context NSStringDrawingContext *drawingContext = [[NSStringDrawingContext alloc] init]; drawingContext.minimumScaleFactor = 0.5; // Half the font size CGRect drawRect = CGRectMake(0.0, 0.0, 200.0, 100.0); [string drawWithRect:drawRect options:NSStringDrawingUsesLineFragmentOrigin attributes:textAttributes context:drawingContext]; </code></pre> <p><strong>Notes:</strong></p> <ul> <li><p>There seems to be a bug in the iOS 7 SDK at least up to version 7.0.3: If you specify a custom font in the attributes, the miniumScaleFactor is ignored. If you pass nil for the attributes, the text is scaled correctly.</p></li> <li><p>The <code>NSStringDrawingUsesLineFragmentOrigin</code> option is important. It tells the text drawing system, that the drawing rect's origin should be at the top left corner.</p></li> <li><p>There is no way to set the baselineAdjustment using the new method. You would have to do that yourself by calling <code>boundingRectWithSize:options:attributes:context:</code> first and then adjusting the rect before you pass it to <code>drawWithRect:options:attributes:context</code>.</p></li> </ul>
    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. This table or related slice is empty.
    1. 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