Growing NSTextView to fit contents is clipping last line of text

孤街醉人 提交于 2019-12-04 07:21:17

I'm not sure if it would be any use, but I wrote a vertically-expanding NSTextView subclass, which is available on GitHub. Feel free to take a look or adjust as you want.

I believe that you are setting the NSTextView's height to the size needed for the textContainer but you aren't accounting for the inset that the text view is adding. Try adding the height of -[NSTextView textContainerInset] to your calculated height.

The documentation doesn't really specify, but I'm assuming that textContainerInset returns the total inset for width/height on all sides and that -[NSTextView textContainerOrigin] would roughly split that in half.

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