Lines missing from tall UILabel when embedding NSTextAttachment

前端 未结 4 1958
陌清茗
陌清茗 2020-12-16 12:12

I can create a multi-line NSAttributedString by using escaped new-line characters (@\"\\n\"). With iOS 7, I can now embed a UIImage in

4条回答
  •  死守一世寂寞
    2020-12-16 12:32

    Did you try to get the actually height of the text using the boundingRectWithSize method:

    NSAttributedString *text;
    CGFloat width = 200;
    CGRect rect = [text boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil];
    CGFloat height = rect.size.height;
    

提交回复
热议问题