alfa
alfa

Reputation: 1

sizeWithFont ios 7.0 deprecated

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.

Upvotes: -5

Views: 168

Answers (2)

Iphonenew
Iphonenew

Reputation: 299

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

Hope it helps...

Upvotes: 0

Jogendra.Com
Jogendra.Com

Reputation: 6454

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

Upvotes: 0

Related Questions