sizeWithFont ios 7.0 deprecated

166 Views Asked by At

I have following warning to use code in iOS 7.0 it will display that use sizeWithAttribute: here is the following code that I have used:

messageSize = [theMessage sizeWithFont:[UIFont systemFontOfSize:20.0]];

if any one have suggestion how to remove the above code with sizeWithAttribute: so please tell me.

2

There are 2 best solutions below

1
Iphonenew On BEST ANSWER
CGSize size = [theMessage sizeWithAttributes:
                       @{NSFontAttributeName:
                         [UIFont systemFontOfSize:20.0f]}];

Hope it helps...

0
Jogendra.Com On

Use sizeWithAttributes: instead, which now takes an NSDictionary. Pass in the pair with key UITextAttributeFont and your font object like this:

CGSize size = [string sizeWithAttributes:
                       @{NSFontAttributeName:
                         [UIFont systemFontOfSize:20.0f]}];

Thanks