{"action":"opened","issue":{"url":"https://api.github.com/repos/ibireme/YYText/issues/165","repository_url":"https://api.github.com/repos/ibireme/YYText","labels_url":"https://api.github.com/repos/ibireme/YYText/issues/165/labels{/name}","comments_url":"https://api.github.com/repos/ibireme/YYText/issues/165/comments","events_url":"https://api.github.com/repos/ibireme/YYText/issues/165/events","html_url":"https://github.com/ibireme/YYText/issues/165","id":135730758,"number":165,"title":"Calculate text height use YYTextLayout question","user":{"login":"meilbn","id":3370355,"avatar_url":"https://avatars.githubusercontent.com/u/3370355?v=3","gravatar_id":"","url":"https://api.github.com/users/meilbn","html_url":"https://github.com/meilbn","followers_url":"https://api.github.com/users/meilbn/followers","following_url":"https://api.github.com/users/meilbn/following{/other_user}","gists_url":"https://api.github.com/users/meilbn/gists{/gist_id}","starred_url":"https://api.github.com/users/meilbn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meilbn/subscriptions","organizations_url":"https://api.github.com/users/meilbn/orgs","repos_url":"https://api.github.com/users/meilbn/repos","events_url":"https://api.github.com/users/meilbn/events{/privacy}","received_events_url":"https://api.github.com/users/meilbn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-02-23T13:00:34Z","updated_at":"2016-02-23T13:00:34Z","closed_at":null,"body":" 首先感谢一下作者！\r\n\r\n根据 README 里的代码，计算文字的高度，但是有点小问题，计算出来的高度总是小于 YYTextContainerView 和 YYTextSelectionView 的高度(在 Reveal 中看到的)，导致有时候最后一行或者几行被切掉了。代码如下：\r\n\r\n```\r\nNSMutableAttributedString *attributedString;\r\n    if (isHTML) {\r\n        attributedString = [[NSMutableAttributedString alloc] initWithData:[text dataUsingEncoding:NSUnicodeStringEncoding]\r\n                                                                     options:@{ NSDocumentTypeDocumentAttribute : NSHTMLTextDocumentType }\r\n                                                          documentAttributes:nil\r\n                                                                       error:nil];\r\n    } else {\r\n        attributedString = [[NSMutableAttributedString alloc] initWithString:text];\r\n    }\r\n    \r\n    attributedString.yy_font = _contentTextView.font;\r\n    attributedString.yy_color = _contentTextView.textColor;\r\n    attributedString.yy_lineSpacing = 8;\r\n    attributedString.yy_lineBreakMode = NSLineBreakByWordWrapping;\r\n    \r\n    _contentTextView.attributedText = attributedString;\r\n    \r\n    CGSize size = CGSizeMake(SCREEN_WIDTH - 12, CGFLOAT_MAX);\r\n    YYTextLayout *layout = [YYTextLayout layoutWithContainerSize:size text:attributedString];\r\n    DDLogDebug(@\"layout.textBoundingRect = %@, layout.textBoundingSize = %@, layout.container.size = %@\",\r\n               NSStringFromCGRect(layout.textBoundingRect),\r\n               NSStringFromCGSize(layout.textBoundingSize),\r\n               NSStringFromCGSize(layout.container.size));\r\n    _contentTextViewHeightConstraint.equalTo(@(layout.textBoundingSize.height));\r\n```\r\n\r\n``_contentTextView`` 为 ``YYTextView``，当文本中有 HTML 标签的时候，比如 ``<br>``，则 isHTML 为 YES，当文本中不包含 HTML 标签，但是包含回车(\\r)或者换行符(\\n)的时候，则为 NO，比如下面的文本：\r\n\r\n```\r\n二十岁的某一天／和你牵手走到天桥边／你兜里只有五块钱／我们吃了一碗牛肉面\\r\\n\\r\\n你说什么爱情都会变／你说你现在也没有钱／你说谢谢我陪你这些天／你说以后不要再被别人骗\\r\\n\\r\\n三十岁的某一天／我和他路过这条街／我说想吃碗牛肉面／他说他身上没零钱\\r\\n\\r\\n我已经想不起你的脸／我也没有你的照片／时间它杀死了所有的从前／我们也没必要再去怀念／你说什么爱情都会变／你说你现在也没有钱／你说谢谢我陪你这些天／你说以后不要再被别人骗\\r\\n\\r\\n八十岁的某一天／我能否再想起你的脸\r\n```\r\n\r\n计算出来的rect、size、container size 为：\r\n\r\n```\r\nlayout.textBoundingRect = {{0, -0.27999999999999936}, {300, 547.89499999999998}},\r\nlayout.textBoundingSize = {300, 548},\r\nlayout.container.size = {308, 1048576}\r\n```\r\n\r\n但是像上面说的，实际上 YYTextContainerView 和 YYTextSelectionView 的高度为 560。\r\n\r\n请问有什么解决办法吗？"}}