How to convert sizeWithFont to sizeWithAttributes(iOS 7)

cgsize, ios7, nsstring, objective-c

Solution

you can try this...

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

[text sizeWithAttributes:attributes]

or

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

Problem

How to get `CGSize` value for a `NSString` in iOS 7 SDK, just want convert the below lines of code with `sizeWithAttributes`. ``` CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:NSLineBreakByWordWrapping]; ```

Original source

Related problems