UILabel truncate tail and skip not complete word

前端 未结 3 1245
后悔当初
后悔当初 2021-01-05 09:40

I have a single line UILabel. It has width = screen width and the content now is (the content of UILabel can change)

You hav

3条回答
  •  孤城傲影
    2021-01-05 09:48

    i am not sure but try it:

    nameLabel.adjustsFontSizeToFitWidth = NO;
    nameLabel.lineBreakMode = NSLineBreakByWordWrapping;
    

    OR

    If you are using storyboard follow these steps i tried this and it working fine

    • Open Attribute Inspector
    • Change Line Breaks to Truncate Tail then

    • Change AutoShrink to Minimum Font Size

    here are my screenshots of label after and before applying these properties

    new output

提交回复
热议问题