且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

NSParagraphStyle行间距被忽略

更新时间:2023-09-18 17:46:16

这是NSHTMLWriter中的一个错误,它是UITextView用于将attributedText转换为HTML的私有类。在内部,它通过UIWebDocumentView显示此HTML。在我的文章中阅读更多关于UITextView内部工作原理的内容: http:// www。 cocoanetics.com/2012/12/uitextview-caught-with-trousers-down/

This is a bug in NSHTMLWriter which is the private class which UITextView uses to convert attributedText into HTML. Internally it displays this HTML via a UIWebDocumentView. Read more on the inner workings of UITextView in my writeup here: http://www.cocoanetics.com/2012/12/uitextview-caught-with-trousers-down/

问题来自于字体CSS中容易遗漏的特色速记。如果您使用字体速记指定像素大小,则会将字体大小和行高设置为BOTH。由于NSHTMLWriter将字体放在行高后,这会导致行高被字体大小抵消。

The problem comes from an easy to miss speciality in the font CSS shorthand. If you specify a pixel size with the font shorthand then this sets BOTH the font-size as well as the line-height. Since NSHTMLWriter puts the font AFTER the line-height this causes the line-height to be cancelled out by the font size.

请参阅此处查看我的雷达,其中包括完整分析错误: http://www.cocoanetics .com / 2012/12 / radar-uitextview-ignores-minimummaximum-line-height-in-attributes-string /

See here for my Radar which includes the full analysis of the bug: http://www.cocoanetics.com/2012/12/radar-uitextview-ignores-minimummaximum-line-height-in-attributed-string/

我建议你提交bug报告并提及我的雷达#12863734。

I suggest you file a bug report as well and mention my Radar #12863734.