I couldn't find any hint to this quite specific question: How can I set the grammar rule by which hyphenation on a UILabel is performed?
You see, my app is localised for english and german language and contains german street names (which obviously will not be translated to english). When the language of the device is set to german, the hyphenation works fine.
But on a device with language set to english, the hyphenation seems to struggle with the german street names (meaning: hyphenation is happening, but in a grammatically wrong way). I assume that's because it is derived from the language set in iOS preferences.
here's how I perform the hyphenation on that label:
func updateStreetNameLabel(streetName: String) {
let paragraphStyle: NSMutableParagraphStyle = NSMutableParagraphStyle()
paragraphStyle.hyphenationFactor = 1.0
paragraphStyle.alignment = .Center
let streetNameWithHyphens: NSMutableAttributedString = NSMutableAttributedString(string: streetName, attributes: [NSParagraphStyleAttributeName : paragraphStyle])
streetNameLabel.attributedText = streetNameWithHyphens
}
I would have thought there was a specific attribute to do this, but I was not able to find out how to go about it. Thanks for any help with this tiny but tricky problem! S.