Replacement for deprecated -sizeWithFont:constrainedToSize:lineBreakMode: in iOS 7?

You could try this:

CGRect textRect = [text boundingRectWithSize:size
                                 options:NSStringDrawingUsesLineFragmentOrigin
                              attributes:@{NSFontAttributeName:FONT}
                                 context:nil];

CGSize size = textRect.size;

Just change “FONT” for an “[UIFont font….]”

Leave a Comment