How can I activate automatic hyphenation in iOS?
I have tried to set the hyphenation factor to 1 in the attributed text options of an UILabel, however I don't get any hyphens though.
Hyphenate text automaticallyOn the Tools menu, click Hyphenation. Select the Automatically hyphenate document check box.
By default, Pages moves words that don't fit on a line of text to the next line. You can have Pages hyphenate those words instead as you type. You can adjust this setting for your entire document or for specific paragraphs.
UITextView
instead of an UILabel
. The hyphenationFactor
(either as a NSParagraphStyle
attribute or as a NSLayoutManager
property) should work then (thanks to the new TextKit).UIWebView
and the -webkit-hyphens
CSS properties.CFStringGetHyphenationLocationBeforeIndex()
function that you mentioned in a comment. This function only gives you a hint about where to put hyphens in a string for a specific language. Then you have to break your lines of text yourself using the Core Text functions (like CTLineCreateWithAttributedString()
and all). See Getting to Know TextKit (the paragraph called Hyphenation explains the logic of the Core Text process, with no code) and Hyphenation with Core Text on the iPad (gives some code sample, but the website seems to be down right now). It's probably going to be more work than you want!If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With