Hyphenation in native iOS app

前端 未结 3 1607
广开言路
广开言路 2020-12-25 08:40

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

3条回答
  •  渐次进展
    2020-12-25 08:45

    Swift version:

    let paragraphStyle = NSMutableParagraphStyle()
    paragraphStyle.hyphenationFactor = 1
    paragraphStyle.alignment = .center
    
    let string = NSAttributedString(string: "wyindywidualizowany indywidualista".uppercased(),
                                    attributes: [NSParagraphStyleAttributeName : paragraphStyle])
    
    myLabel.attributedText = string
    

提交回复
热议问题