UILabel text truncation vs. line breaks in text

前端 未结 2 1914
深忆病人
深忆病人 2020-12-04 03:24

I have a UILabel that is put as titleView in the navigation bar. I want it to have 2 lines, where the first line can be truncated and the second is center align

2条回答
  •  天命终不由人
    2020-12-04 04:04

    change your line breakmode to ByTruncatingMiddle instead of ByTruncatingTail. Something like below,

        label.lineBreakMode = .ByTruncatingMiddle
    

    Hope this will help :)

提交回复
热议问题