Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use drawInRect:withAttributes: instead of drawAtPoint:forWidth:withFont:fontSize:lineBreakMode:baselineAdjustment: in iOS 7
    primarykey
    data
    text
    <p>This method is deprecated in iOS 7.0:</p> <pre><code>drawAtPoint:forWidth:withFont:fontSize:lineBreakMode:baselineAdjustment: </code></pre> <p>Now use <code>drawInRect:withAttributes:</code> instead.</p> <p>I can't find the attributeName of fontSize and baselineAdjustment. </p> <p><strong>Edit</strong> </p> <p>Thanks @Puneet answer. </p> <p>Actually, I mean if there doesn't have these key, how to implement this method in iOS 7? </p> <p>Like below method:</p> <pre><code>+ (CGSize)drawWithString:(NSString *)string atPoint:(CGPoint)point forWidth:(CGFloat)width withFont:(UIFont *)font fontSize:(CGFloat)fontSize lineBreakMode:(IBLLineBreakMode)lineBreakMode baselineAdjustment:(UIBaselineAdjustment)baselineAdjustment { if (iOS7) { CGRect rect = CGRectMake(point.x, point.y, width, CGFLOAT_MAX); NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; paragraphStyle.lineBreakMode = lineBreakMode; NSDictionary *attributes = @{NSFontAttributeName: font, NSParagraphStyleAttributeName: paragraphStyle}; [string drawInRect:rect withAttributes:attributes]; size = CGSizeZero; } else { size = [string drawAtPoint:point forWidth:width withFont:font fontSize:fontSize lineBreakMode:lineBreakMode baselineAdjustment:baselineAdjustment]; } return size; } </code></pre> <p>I don't know how to pass <code>fontSize</code> and <code>baselineAdjustment</code> to </p> <p><code>attributes</code> dictionary. </p> <p>e.g.</p> <p><code>NSBaselineOffsetAttributeName</code> key should pass a <code>NSNumer</code> to it, but the <code>baselineAdjustment</code> is <code>Enum</code>. </p> <p>Isn't there have other way to pass the two variables?</p>
    singulars
    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.
 

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