I want to ask how to se开发者_运维技巧t the size of the white space in CoreText? I want to make the CoreText white space have same size with UITextView white space. Anybody can help me?
You are unlikely to ever get this QUITE right. Using the debugger/Instruments you can see that UITextViews draw their text using WebKit, which puts a very big "black box" between what you can control on the UITextView itself and the underlying, highly generalized text-drawing code it eventually uses for drawing. What's more, Apple can change the behavior of UITextView and make it different from your CoreText-drawn text in the future. Having tried to achieve the exact same effect myself, I can tell you that down this road lies only pain. I would strongly suggest taking an alternate approach.
If your goal is to have the text rendering between a custom view and a UITextView line up perfectly, and you MUST use the UITextView, I would suggest looking into using WebKit for text rendering in your custom view, instead of going to CoreText directly. But no matter what way you do it, you're looking at a lot of work, and you're implicitly depending on Apple to not tweak their text rendering in the future.
Good luck.
精彩评论