How do I set a UILabel lineBreakMode to break words and add hyphens to broken words?
a label with a broken wo-
rd should look like this
How do I set a UILabel lineBreakMode to break words and add hyphens to broken words?
a label with a broken wo-
rd should look like this
This will help you. please Change Uilabel Text plain to Attributed
Elaborating on Matt's answer here: https://stackoverflow.com/a/16502598/196358 it can be done using NSAttributedString and NSParagraphStyle. See below:
This will cause the label to break at logical places mid-word using hyphens. It looks great, and is pretty simple to do. It requires iOS 6.0, but I've only tried it under 7.0.
Sometimes it's crucial to add a
locale
attribute key.I can't delete this as it was accepted, but I am wrong from today's POV.
EARLIER UILabel did not offer Hyphenation.
TODAY it does through NSAttributedString (ios6+)
see: Orthographic hyphenation word in IOS 6.x
Swift 4.0
Swift 3.0
From Storyboard