NSStringã¯ã©ã¹ã®drawInRect:withFont:lineBreakMode:alignment:ã¡ã½ãã
ã¯ãiOS 7.0ãããdeprecated(éæ¨å¥¨)ãã¨ãªããä¸å³ã®ãããªã¯ã¼ãã³ã°è¡¨ç¤ºãããããã«ãªãã¾ããã
横ã«é·ãããå ¨æ表示ãã§ãã¦ãã¾ããããä¸è¨ã®ãããªã¯ã¼ãã³ã°ã表示ããã¦ãã¾ãã
'drawInRect:withFont:lineBreakMode:alignment:' is deprecated: first deprecated in iOS 7.0 - Use -drawInRect:withAttributes:
ã¤ã¾ããæ¢åã®drawInRect:withFont:lineBreakMode:alignment:ã¡ã½ãã
ã使ç¨ãããã¨ã¯iOS 7.0ããã¯éæ¨å¥¨ãªã®ã§ãdrawInRect:withAttributes:ã¡ã½ãã
ã使ãããã«ãã¾ããããã¨ãããã¨ã§ãã
ãã¦ã以ä¸ã®ãµã³ãã«ã³ã¼ããiOS 7.0åãã«drawInRect:withAttributes:ã¡ã½ãã
ã使ãããã«å¤æ´ãã¦ã¿ã¾ãããã
iOS 7.0ã¾ã§ã®æååæç»
// ãã©ã³ããªãã¸ã§ã¯ããçæãã UIFont *font = [UIFont boldSystemFontOfSize:11.0]; // æåã¯ç½è²ã§æç»ãã [[UIColor whiteColor] set]; // text ãæç»ãã [text drawInRect:CGRectMake(0, 0, 320, 50) withFont:font lineBreakMode:NSLineBreakByClipping alignment:NSTextAlignmentCenter];
iOS 7.0ããã®æååæç»
// ãã©ã³ããªãã¸ã§ã¯ããçæãã UIFont *font = [UIFont boldSystemFontOfSize:11.0]; // ãã©ã°ã©ãã§æåã®æç»ä½ç½®ãªã©ãæå®ãã NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; style.lineBreakMode = NSLineBreakByWordWrapping; style.alignment = NSTextAlignmentCenter; // text ã®æç»ããéã®è¨å®(å±æ§)ãæå®ãã NSDictionary *attributes = @{ NSForegroundColorAttributeName : [UIColor whiteColor], NSFontAttributeName : font, NSParagraphStyleAttributeName : style }; // text ãæç»ãã [text drawInRect:CGRectMake(0, 0, 320, 50) withAttributes:attributes];