Get Width of last line of multiline UILabel

前端 未结 2 1585
旧巷少年郎
旧巷少年郎 2021-01-18 06:32

I have a dynamic multi line UILabel and need to know the end of the text (X Coordinate) of the visible text (not the Label) so I can show something after the text. Is this p

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-18 06:58

    As far as I know , the best solution for this is to use a UIWebView instead of a UILabel. You just have to format the HTML for it to load and then add whatever you want to add after.

    Example:

    [webView loadHTMLString:[NSString stringWithFormat:@"%@ %@",text1 , text2] baseURL:nil];
    

    If you want to keep trying with UILabel / UITextView /any UIView for that matter , I only know of a way to figure out the height properly : [myView sizeToFit]; And then get it's frame.

    Hope this helps.

    Regards,

    George

提交回复
热议问题