UILabel sizeToFit method not working properly

后端 未结 6 1050
梦如初夏
梦如初夏 2021-01-01 11:52

I\'m trying to show a long chunk of text inside a UILabel in one line. The UILabel is a subview of UIScrollView so I can scroll and see the entire UILabel.

My proble

6条回答
  •  感情败类
    2021-01-01 12:26

    Since you have restricted your Label to show only one line of Text and truncate the rest , it is behaving the same

    textLabel.attributedText = attributedString;
    textLabel.numberOfLines = 0;
    [textLabel sizeToFit];
    textLabel.lineBreakMode = NSLineBreakByWordWrapping;
    textScrollView.contentSize = CGSizeMake(textLabel.frame.size.width, textLabel.frame.size.height);
    

    Hope it will help you

提交回复
热议问题