Adding hyphens to the main text?

I am trying to add wrapping to a drawing string using Core Text. So far, I have found an extension of this category in NSString that tries to add hyphens, but it is deprecated and does not work when the line has apostrophes, as well as many other questions. And then this other guy uses this code for this, but it depends on the first source code, which is not good.

But now in iOS 5, apparently, the built-in transfer method is portable, although the tutorials and examples are extremely scarce: CFStringGetHyphenationLocationBeforeIndex . Can someone more experienced with Core Text and CF prepare a quick example of how I can potentially use this feature?

+4
source share
1 answer

OK, for a category to work, you just need to use [token length] instead of strlen(tokenChars) (line 112). CFStringGetHyphenationLocationBeforeIndex just replaces the core part here http://frankzblog.appspot.com/?p=7001 This method really works if you have a simple CTFrameRef (with CGPath as a rectangle).

+2
source

Source: https://habr.com/ru/post/1412264/


All Articles