Label 設定AttributedText後,需重新指定LineBreakMode

titleLabel.attributedText = NSMutableAttributedString(string: viewModel.model.title, attributes: titleAttributes)


// Make sure lineBreakMode put below attributedText
titleLabel.lineBreakMode = NSLineBreakMode.byTruncatingTail
 

參考資料:

https://stackoverflow.com/questions/37207762/nsattributedstring-tail-truncation-in-uilabel

arrow
arrow
    全站熱搜

    小賢 發表在 痞客邦 留言(0) 人氣()