-2
我正在使用此代码导致不同版本的ios的不同值。CGSize为ios版本7和8提供了不同的值
CGSize textSize = [title sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14.0f]}];
我正在使用此代码导致不同版本的ios的不同值。CGSize为ios版本7和8提供了不同的值
CGSize textSize = [title sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14.0f]}];
我想你的代码:
NSString* title = @"Hey nonny nonny we like to party";
CGSize textSize = [title sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14.0f]}];
NSLog(@"%@", NSStringFromCGSize(textSize));
我得到了这些结果。 iOS的7:
2015-05-22 07:50:22.266 Test[1153:607] {214.49399999999994, 16.701999999999998}
的iOS 8:
2015-05-22 07:49:57.957 Test[1090:31606] {214.49399999999994, 16.701999999999998}
看起来是一样的我。我不得不猜测你的测试过程有什么问题。
这是什么问题?你想让它们返回相同的值吗? 看看这个问题http://stackoverflow.com/questions/25855472/nsstring-sizewithattributes-returns-different-height-in-ios-8-versus-ios-7 – Erakk
对于相同的文本,它应该返回相同的值为ios版本7和8但其返回不同 –
我没有使用任何换行符,使用简单的文本作为“abc” –