1

I know there are lots of answers to similar questions but I have tried and tried but can't any of the replacements to work. The problem line is below where I am getting the error sizeWithFont is deprecated use boundingRectWithSize: options: attributes: context:

    CGSize contentSize = [myString sizeWithFont:[UIFont fontWithName:@"arial" size:12] constrainedToSize:CGSizeMake(650, CGFLOAT_MAX) lineBreakMode:NSLineBreakByWordWrapping];

I have also seen that sizeWithAttributes should be used. And I have also seen that some replacement code is a number of lines long which hardly seems a step forward.

Can anyone help me with the correct replacement line?

Update:

I have tried

CGSize contentSize = [myString sizeWithAttributes: @{NSFontAttributeName: [UIFont fontWithName:@"Helvetica" size:12]}];

but that still leaves the

constrainedToSize:CGSizeMake(650, CGFLOAT_MAX) lineBreakMode:NSLineBreakByWordWrapping];

Is this no longer needed?

RGriffiths
  • 5,722
  • 18
  • 72
  • 120
  • 1
    possible duplicate of [Replacement for deprecated sizeWithFont: in iOS 7?](http://stackoverflow.com/questions/18897896/replacement-for-deprecated-sizewithfont-in-ios-7) - if none of the answers there are appropriate for you, please explain why in greater detail. – Aaron Brager Mar 13 '14 at 15:16
  • Yes but not a complete answer - there is no replacement for constrainedToSize:CGSizeMake(650, CGFLOAT_MAX) lineBreakMode:NSLineBreakByWordWrapping]; – RGriffiths Mar 13 '14 at 15:25
  • You can using http://stackoverflow.com/a/18951386/1445366 – Aaron Brager Mar 13 '14 at 17:41

0 Answers0