NSString sizeWithAttributes: returns different height in iOS 8 versus iOS 7

僤鯓⒐⒋嵵緔 提交于 2020-01-06 20:36:33

问题


The line below returns a size with a larger height when I run it on an iOS8 device versus iOS7. It happens regardless of whether I'm building with iOS 7 or iOS 8 as my base SDK. Anyone else seeing this issue?

return [myString sizeWithAttributes:attributes];

回答1:


I answered my own question. The issue occurs when the string ends in a line break as below. This causes an issue because iOS 7 ignores trailing line breaks but iOS 8 doesn't.

myString = @"Some text.\n";

Removing the trailing line breaks before calling sizeWithAttributes: fixes the problem.



来源:https://stackoverflow.com/questions/25855472/nsstring-sizewithattributes-returns-different-height-in-ios-8-versus-ios-7

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!