Objective c 如何将sizeWithFont转换为sizeWithAttributes(iOS 7)

Objective c 如何将sizeWithFont转换为sizeWithAttributes(iOS 7),objective-c,ios7,nsstring,cgsize,Objective C,Ios7,Nsstring,Cgsize,如何在iOS 7 SDK中为NSString获取CGSize值,只需将以下代码行转换为sizeWithAttributes CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:NSLineBreakByWordWrapping]; 你可以试试这个 NSDictionary *attributes = @{NSFontAtt

如何在iOS 7 SDK中为
NSString
获取
CGSize
值,只需将以下代码行转换为
sizeWithAttributes

CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:NSLineBreakByWordWrapping];
你可以试试这个

 NSDictionary *attributes = @{NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue" size:14]};

[text sizeWithAttributes:attributes]

可能重复的
CGRect rect = [text boundingRectWithSize:CGSizeMake(width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes context:nil];