2

I have CCLabelTTF with NSString text. On the 5th IOS sizeWithFont: returns height bigger then sizeWithAttributes: on the 7th.

if ([[[UIDevice currentDevice] systemVersion] compare:@"7.0" options:NSNumericSearch] == NSOrderedAscending)
{
     dim = [string sizeWithFont:font];
}
else
{
     dim = [string sizeWithAttributes:[NSDictionary dictionaryWithObject:[UIFont fontWithName:name size:(CGFloat)size] forKey:NSFontAttributeName]];
}

dim differs on 1 pixel for 5 and 7 ios
eilas
  • 373
  • 6
  • 17
  • Are you sure the same attributes are being passed in both cases? – trojanfoe Oct 07 '13 at 13:56
  • sizeWithFont is deprecated you must only use sizeWithAttributes. In your case the reason could be that as now it is an attributed string that is used and in case you use both, the sizeWithFont will only calculate the width without any attributes. – HpTerm Oct 07 '13 at 14:01
  • sizeWithFont is deprecated only on the 7 ios, so I use sizeWithAttributes for it. – eilas Oct 07 '13 at 14:56

0 Answers0