开发环境:Swift 2.3
问题代码:
let lb = UILabel(frame:frame)
lb.numberOfLines = 2
lb.lineBreakMode = .ByTruncatingTail
lb.attributedText = ....
如果不用lb.attributedText, 而使用text的话,没任何问题。NSMutableParagraphStyle中有设置lb.lineBreakMode的。如果在NSMutableParagraphStyle中没有显性的设置lineBreakMode的话,就会被重置掉。
解决方法1:
let mps = NSMutableParagraphStyle()
mps.lineBreakMode = .ByTruncatingTail
解决方法2:
lb.attributedText = ....
lb.lineBreakMode = .ByTruncatingTail